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

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -