开发者

Detecting normal minus and numpad minus in JavaScript onKeyDown

开发者 https://www.devze.com 2023-02-01 10:51 出处:网络
In JavaScript\'s event onKeyDown, 开发者_StackOverflowis there anyway to differentiate a minus sign pressed in the \"normal\" keyboard area from one pressed in the numpad? I think they generate the sa

In JavaScript's event onKeyDown, 开发者_StackOverflowis there anyway to differentiate a minus sign pressed in the "normal" keyboard area from one pressed in the numpad? I think they generate the same which code (at least in FireFox).

I'm trying to map an standard qwerty layout to a different keyboard mapping in a text area as a user types in, and want to ignore anything on the numeric pad.

Let me know if I'm unclear.


I doubt you'll be able to do it reliably cross-browser. There's an excellent writeup of keyboard events and the codes generated on various browsers on this page. I think it's getting pretty dated now, though.

0

精彩评论

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