JSFiddle - React, Tailwind, and code Playground
by Paulpro
JavaScript
document.onkeydown = function(e){
var keycode = window.event ? window.event.keyCode : e.which;
if(keycode == 40){
var timer = setTimeout(function(){
alert('Down key held');
document.onkeyup = function(){};
}, 200);
document.onkeyup = function(){
clearTimeout(timer);
alert('Down key pressed');
}
}
};