Detecting normal minus and numpad minus in JavaScript onKeyDown
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.
精彩评论