Skip to content Skip to sidebar Skip to footer

How To Get String/character Value From Key Code;

I am using an input tag of html which is supposed to work similar to input of google search. function onKeyPressFun(event){ var inputObj = document.getElementById('tagInput');

Solution 1:

It may have something to do with support for .keyCode property across different browsers. Normalize keyCode value to get better results. One way to do it (part in parentheses is from jQuery source):

// e.g.
String.fromCharCode(event.charCode != null ? event.charCode : event.keyCode);

Solution 2:

You can try:

String.fromCharCode(event.which); // it works in all major browsers

Post a Comment for "How To Get String/character Value From Key Code;"