Keyboard keycode

 1, keyboard press monitor global events, such as monitor global Enter event

. 1   $ (Document) .keydown ( function (Event) {
 2    IF (== 13 is event.keyCode ) {
 . 3      Alert ( 'you press the Enter'); 
 . 4    }
 . 5   });

 2, a component monitor keyboard press events, such as listening id Enter button press event for the assembly of btn

. 1   . $ ( "BTN #") keyDown ( function (Event) {
 2    IF (== 13 is event.keyCode ) {
 . 3      Alert ( 'you press the Enter'); 
 . 4    }
 . 5   });

 3, if the key combination is to monitor, for example, monitor ctrl + c

. 1   $ (Document) .keyup ( function (Event) { 
 2    IF (event.ctrlKey && === event.keyCode 67 ) { 
 . 3       Alert ( '+ C you press the CTRL' ); 
 . 4    } 
 . 5   });

 4, a detailed list of values ​​keyCode

 

 1, keyboard press monitor global events, such as monitor global Enter event

. 1   $ (Document) .keydown ( function (Event) {
 2    IF (== 13 is event.keyCode ) {
 . 3      Alert ( 'you press the Enter'); 
 . 4    }
 . 5   });

 2, a component monitor keyboard press events, such as listening id Enter button press event for the assembly of btn

. 1   . $ ( "BTN #") keyDown ( function (Event) {
 2    IF (== 13 is event.keyCode ) {
 . 3      Alert ( 'you press the Enter'); 
 . 4    }
 . 5   });

 3, if the key combination is to monitor, for example, monitor ctrl + c

. 1   $ (Document) .keyup ( function (Event) { 
 2    IF (event.ctrlKey && === event.keyCode 67 ) { 
 . 3       Alert ( '+ C you press the CTRL' ); 
 . 4    } 
 . 5   });

 4, a detailed list of values ​​keyCode

 

Guess you like

Origin www.cnblogs.com/wangchao688/p/12602297.html