Some desktop apps treat the ‘carriage return’ key and the numpad’s ‘enter’ key differently. I’ve noticed that these two keys generate the same keyCode (13) in Javascript (jQuery).
Are they converted to be equal in the browser environment, or is it possible to differentiate between them (ie. make the CR make a new line in a text area, and the ‘enter’ key submit it’s form ?
See Jan Wolters’ treatise on Javascript Madness: Keyboard Events.
EnterandNumpad Enterboth give the same keycode, i.e. 13, because browsers do not differentiate between the two keys. To be honest, nor do most environments. It is possible to differentiate between them using the Windows API (for example), but it does take extra effort to do so. This, however, falls outside the scope of the browser’s abstraction.UPDATE
As Bill Thorne rightfully mentions, the
KeyboardEventobject sports alocationproperty nowadays.From the Mozilla Developer Network: