views:

41

answers:

2

Hi folks,

any cool libraries that you know about around? =)

+1  A: 

This jquery event.which example pretty much does what you want.

Pat
+2  A: 

Hard to tell exactly what you're asking, but if you're handling an event that gives you a charCode, such as keypress, you can use

var str = String.fromCharCode(event.charCode);

// or
var str = String.fromCharCode(event.which);

to get the value of the key that was pressed.

https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/String/fromCharCode

Andy E
In IE you bizarrely have to use the `keyCode` property to get the character code in the `keypress` event
Tim Down
@Tim Down, yes I actually forgot about that. The OP tagged jQuery, though, so the event object should be consistent across browsers for jQuery bound events.
Andy E