How to convert key code to character using javascript

How to convert key code to character using javascript

var key_code = 65; 

the result should be

 character = "a"; 
+58
javascript variables keycode
Oct 20 2018-10-10
source share
2 answers

String.fromCharCode() is what you want:

The fromCharCode () method converts Unicode values ​​to characters.

Syntax

 String.fromCharCode(n1, n2, ..., nX) 
+115
Oct. 20 2018-10-10
source share

As seen here :

 String.fromCharCode((96 <= key && key <= 105) ? key-48 : key) 
+8
Mar 17 '15 at 12:49
source share



All Articles