Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery keypress except: {something}

Is there any shortcut( actually a function) in jQuery or Javascript to handle button press except something, or only something, e.g.:

$(input).keypress('nonfunctional' function(){ 
  // do something
});

that will trigger only on [a-z][0-9] buttons pressed and ignoring single shift or ctrl but handling shift+a => A pressed?

P.S.i do know about if(key.code == 123) then ...

like image 352
ted Avatar asked Jan 22 '13 13:01

ted


People also ask

Is Onkeypress deprecated?

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes.

What is Keyup and Keydown in jQuery?

Definition and Usagekeydown - The key is on its way down. keypress - The key is pressed down. keyup - The key is released.

How does jQuery detect keyboard press?

The keypress() method in jQuery triggers the keypress event whenever browser registers a keyboard input. So, Using keypress() method it can be detected if any key is pressed or not.

Why is KeyCode deprecated?

KeyCode was deprecated because in practice it was “inconsistent across platforms and even the same implementation on different operating systems or using different localizations.” The new recommendation is to use key or code .


1 Answers

No, if you want to exclude specific keys that's what the event.keyCode / event.which properties are there for.

like image 132
James Avatar answered Sep 24 '22 14:09

James