DEV Community

San
San

Posted on

How to convert ASCII code to character using JavaScript ?

How to convert ASCII code to character using JavaScript ?

For example, the ordinary number key 1 generates an event with keycode 49 while numberpad key 1 (with Numlock on) generates keycode 97. Used with String.fromCharCode we get the following:

Output:

console.log(String.fromCharCode(65))
console.log(String.fromCharCode(66))
console.log(String.fromCharCode(67))
console.log(String.fromCharCode(89))
console.log(String.fromCharCode(90))
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay