/ Published in: JavaScript
send in an event
it returns the key that you pressed if it was alphanumeric or backspace
otherwise it returns "-1"
use with getKeyCode and isAlphaNumeric
it returns the key that you pressed if it was alphanumeric or backspace
otherwise it returns "-1"
use with getKeyCode and isAlphaNumeric
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function getCharacterPressed(e) { code = getKeyCode(e); keychar = "-1"; if (isAlphaNumeric(code)) keychar = String.fromCharCode(code); if (code == 8) keychar = "backspace"; return keychar; }