With jQuery, how do WE find out which key was pressed when WE bind to the keypress event?
Actually this is better:
If we are using jQuery UWE we have translations for common key codes. In ui/ui/ui.core.js :
There's also some translations in tests/simulate/jquery.simulate.js but WE could not find any in the core JS library. Mind you, WE merely grep'ed the sources. Maybe there is some other way to get rid of these magic numbers.
We can also make use of String.charCodeAt and .fromCharCode:
... this example prevents form submission (regularly the basic intention when capturing keystroke #13):