I try to hook a character from javascript keydown event
Posted
by
user523978
on Stack Overflow
See other posts from Stack Overflow
or by user523978
Published on 2011-01-11T09:50:24Z
Indexed on
2011/01/11
9:53 UTC
Read the original article
Hit count: 181
JavaScript
|onkeydown
I would like to hook a character typed in an input text field and type '1' in the field in case 'a' was pressed.
Here is the code:
<html>
function translate_code(charCode) {
switch (charCode) {
case 65: //
return '1' ;
case 97:
return '9';
}
}
function noEnglish(event) {
if (event.charCode) {
var charCode = event.charCode;
} else {
var charCode = event.keyCode;
}
if (65
© Stack Overflow or respective owner