Reddy
Reddy

Reputation: 1385

Problem capturing keycode

 $(document).bind('keypress', function(e) {
 var code = (e.keyCode ? e.keyCode : e.which);
 alert(code)
 });

The above code is not returning anything if i click alt,start,prtscrcn etc..
Please someone help me..

Upvotes: -1

Views: 118

Answers (2)

nnnnnn
nnnnnn

Reputation: 150070

Did you read the jQuery doco on keypress?

keypress doesn't get triggered by "modifier" keys like shift, alt, etc. Use keyup or keydown instead.

Note that alt tends to activate the browser's menu, so subsequent keypresses may not register in your web page.

There are several web sites where you can try out the differences between keypress, keyup and keydown.

Upvotes: 3

Jason Kaczmarsky
Jason Kaczmarsky

Reputation: 1686

Works fine for me: Examples (Click in the result box, then type)

I think you just missed a semicolon.

Upvotes: 0

Related Questions