javascript - detect ctrl key pressed or up, keypress event doesn't trigger -
i see similar questions here (like javascript: check if ctrl button pressed) problem event triggering. js code:
// listen keyboard. window.onkeypress = listentothekey; window.onkeyup = listentokeyup; /* gets key pressed , send request associated function @input key */ function listentothekey(e) { if (editflag == 0) { // if delete key pressed calls delete if (e.keycode == 46) deletenode(); // if insert key pressed calls add blank if (e.keycode == 45) createblank(); if (e.keycode == 17) ctrlflag = 1; } }
the event triggers other keys except ctrl.
need trigger ctrl.
can't use jquery/prototype/whatever solutions not acceptable.
so... how can detect ctrl?
try using if (e.ctrlkey)
.
Comments
Post a Comment