views:

39

answers:

2
$("#text").bind('keypress', function(e) {
    var code = (e.KeyCode ? e.keyCode : e.which);  
    alert(code);
}

It works fine for everything except Alt Ctrl Shift.
But in all tutorials that i found it should echos 17, 18, 19

Why?

+3  A: 

use .keydown() or .keyup()

see it in action

Reigel
A: 

Have you considered using the jquery.hotkeys extension that allows you to bind by specifying a string?

"C-A-q" would bind you to Control + Alt + 'q'.
Andrew Matthews
the OP did not mention about any combination keys :)
Reigel
Considering what his code is (probably) going to be used for, it is a viable alternative. :P
Andrew Matthews