Reputation: 1385
$(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
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
Reputation: 1686
Works fine for me: Examples (Click in the result box, then type)
I think you just missed a semicolon.
Upvotes: 0