javascript - jQuery which to detect empty space -
i trying figure out when key press empty space, did following:
if (e.which == ' '){ } however not work. idea why?
event.which returns code of character pressed. space key code 32, use instead:
if (e.which === 32) { // } another way convert character char code .charcodeat():
if (e.which === " ".charcodeat(0)) { // } check: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
Comments
Post a Comment