找出按下的字符 [英] Find out the character pressed key

查看:28
本文介绍了找出按下的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我给KeyboardEvent.KEY_DOWN 添加一个监听器,我可以找出keyCode 和charCode.

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

keyCode 根据键盘映射到不同的字符.

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

根据帮助,charCode 也同样没用:

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

字符代码值为英文键盘值.例如,如果按 Shift+3,则 charCode 在日语键盘上为 #,就像在英语键盘上一样.

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.

那么,我怎样才能知道用户按下了哪个字符?

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

推荐答案

您遗漏了引文的一个非常重要的部分,或者在找到它的地方丢失了:

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

例如,如果您按 Shift+3,则getASCIICode() 方法在 a 上返回 #日语键盘,就像它一样英文键盘.

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/flash/events/KeyboardEvent.html

这可能更有帮助:

charCode 属性是该键在当前字符集中的数值(默认字符集是 UTF-8,支持 ASCII).

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

您的应用程序决定使用什么字符集,这意味着即使您必须使用不同键盘本地的不同键来生成相同的字符,它也将具有相同的 charCode.

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.

这篇关于找出按下的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆