سؤال

This question already has an answer here:

How to convert keycode to character using javascript

var key_code = 65;

result should be

character = "a";
هل كانت مفيدة؟

المحلول

String.fromCharCode() is what you want:

The fromCharCode() method converts Unicode values to characters.

Syntax

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

نصائح أخرى

As seen here:

String.fromCharCode((96 <= key && key <= 105) ? key-48 : key)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top