How to convert keycode to character using javascript

faressoft picture faressoft · Oct 20, 2010 · Viewed 100.7k times · Source

How to convert keycode to character using javascript

var key_code = 65;

result should be

character = "a";

Answer

Skilldrick picture Skilldrick · Oct 20, 2010

String.fromCharCode() is what you want:

The fromCharCode() method converts Unicode values to characters.

Syntax

String.fromCharCode(n1, n2, ..., nX)