开发者

Mapping keystrokes to actual value? - Javascript

开发者 https://www.devze.com 2023-01-08 17:48 出处:网络
any cool libraries that you know about around? 开发者_如何学Python=)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

any cool libraries that you know about around? 开发者_如何学Python=)


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号