找出字符pressed关键字符、关键、pressed

2023-09-08 13:40:51 作者:為{幸葍}努か

如果我添加一个监听器KeyboardEvent.KEY_DOWN,我可以找出关键code和字符code。

If I add a listener to KeyboardEvent.KEY_DOWN, I can find out the keyCode and the charCode.

关键code映射到不同的键盘上的一个不同的角色。

The keyCode maps to a different character depending on the keyboard.

该字符code是一样没用,根据帮助:

The charCode is just as useless, according to the help:

字符code值为英文键盘值。例如,如果preSS SHIFT + 3,字符code#是在日文键盘上,只是因为它是在英文键盘上。

The character code values are English keyboard values. For example, if you press Shift+3, charCode is # on a Japanese keyboard, just as it is on an English keyboard.

所以,我怎么能找出哪些字符,用户pressed?

So, how can I find out which character the user pressed?

推荐答案

您留下了pretty的报价的重要组成部分,或者它缺少在哪里找到它:

You left out a pretty important part of the quote or it was missing where you found it:

例如,如果preSS SHIFT + 3,   getASCII code()方法返回#上一个   日文键盘,只是因为它在   在英文键盘。

For example, if you press Shift+3, the getASCIICode() method returns # on a Japanese keyboard, just as it does on an English keyboard.

http://livedocs.adobe.com/flex/ 201 / langref /闪光灯/事件/ KeyboardEvent.html

这可能是更有益的:

该字符code属性是当前字符集项的数值(默认字符集是UTF-8,它支持ASCII)。

如何用Excel统计某字符或关键字出现的次数

The charCode property is the numeric value of that key in the current character set (the default character set is UTF-8, which supports ASCII).

http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00000480.html

您的应用程序设置来确定使用哪些字符,这意味着,即使你不得不使用不同的键盘当地人独立的密钥产生相同的字符,就会有相同的字符code。

Your application determines what characters set is used, meaning that the even if you have to use separate keys of different keyboard locals to produce the same character, it will have the same charCode.