Is keyevent a number key event - Node.js DOM

Node.js examples for DOM:Event

Description

Is keyevent a number key event

Demo Code

function IsDigit( e )
{
  e = e || event ;/*from w  w w.  ja v  a2 s  .  c o  m*/
  var iCode = ( e.keyCode || e.charCode ) ;

  event.returnValue =
    (
      ( iCode >= 48 && iCode <= 57 )    // Numbers
      || (iCode >= 37 && iCode <= 40)    // Arrows
      || iCode == 8            // Backspace
      || iCode == 46            // Delete
    ) ;

  return event.returnValue ;
}

Related Tutorials