The Little Guy Posted March 26, 2009 Share Posted March 26, 2009 How do I check to see if a user is holding the Ctrl button? I don't want it pressed, I would like it to be held down. Quote Link to comment https://forums.phpfreaks.com/topic/151273-solved-hold-key/ Share on other sites More sharing options...
The Little Guy Posted March 26, 2009 Author Share Posted March 26, 2009 Got it! Use it if you wish! document.onkeydown = pressBtn; document.onkeyup = releaseBtn; var pushed = false; function pressBtn(e){ if(e.keyCode == 17) pushed = true; } function releaseBtn(e){ if(e.keyCode == 17) pushed = false; } if(pushed) alert('im down'); if(!pushed) alert('im up'); Quote Link to comment https://forums.phpfreaks.com/topic/151273-solved-hold-key/#findComment-794643 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.