Jump to content

[SOLVED] Hold Key


The Little Guy

Recommended Posts

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');

Link to comment
https://forums.phpfreaks.com/topic/151273-solved-hold-key/#findComment-794643
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.