I currently have a div element. Is there a way in Javascript that when we press the Ctrl key, the div shows up, and when we release (unpress) the key, the div disappear? Thank you! (something like onClick...) (Ctrl key code is 17)
Asked
Active
Viewed 39 times
0
-
1No! This is not a duplicated question! The link you gave me can't solve it! Please release this question to normal – Lan Mai Feb 01 '17 at 07:57
-
1Maybe you could bind the keydown event on the window with `$(window).bind('keydown', function(event) { if (event.keyCode == KEY_CODE_OF_CTRL_KEY) { $(div).show(); }});`. To disapear on keyup you have to do the same just vice versa. – Patrick Vogt Feb 01 '17 at 08:29
-
Thanks a lot man! I found out about onkeydown and onkeyup :) – Lan Mai Feb 01 '17 at 08:42
-
You're welcome. This sounds great. If my comment was helpful, then vote it up please. – Patrick Vogt Feb 01 '17 at 08:45
-
Dome it. Have a good day – Lan Mai Feb 01 '17 at 08:55