在AS3中捕获大写字母
好的,我知道如何捕捉常见的小写字母。我正在使用 KeyboardEvent.KEY_DOWN 并将代码与 ASCII 表进行比较,以找出按下了哪个键。现在,我也希望能够找出是否有,例如按下 SHIFT+A,但我不知道如何实现这一点。我的意思是,在我的程序中,SHIFT 和 A 是完全不同的键,彼此无关,按下时它们都会调用 KeyboardEvents。在格鲁吉亚语字母表中,某些字母是通过 SHIFT 和英文字母组合输入的,例如格鲁吉亚语键盘上的 W 表示 წ,而 SIFT+W 表示 ჭ。正如您所看到的,完全不同的字母。我希望能够同时抓住这两个方面,因为我目前正在开发格鲁吉亚语游戏。任何帮助将不胜感激。提前致谢 :-)
Okay, I know how to catch usual lowercase letters. I'm using KeyboardEvent.KEY_DOWN and compare the code to the ASCII table to find out which key was pressed. Now, I also want to be able to find out if there is, for example SHIFT+A pressed, and I have no idea how to implement this. I mean, in my program SHIFT and A are absolutely different keys which have nothing to do with each other, and they both will call KeyboardEvents when pressed. In Georgian alphabet some letters are typed by combination of SHIFT and English letters, for example W on Georgian keyboard means წ, when SIFT+W means ჭ. Absolutely different letters, as you can see. And I want to be able to catch both, coz I'm currently developing Georgian-language game. Any help will be appreciated. Thanks in advance :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下 KeyEvent 类。它为您提供有关是否按下 Shift 键的信息。看这个例子:
这是一个示例输出:
正如您所看到的,KeyboardEvent.keyCode 和 KeyboardEvent.shiftKey 的组合保存了您正在查找的信息。
Take a look at the KeyEvent class. It provides you with the infos on if the shift key was pressed or not. Look at this example:
This is an example output:
As you can see the combination of KeyboardEvent.keyCode and KeyboardEvent.shiftKey hold the information which you are looking for.
您应该使用 KeyboardEvent.charCode (它提供了英文代码,您需要将其映射到您的格鲁吉亚键盘布局。)当大写锁定打开时,按 Shift 键可能会给出小写字母。
You should use KeyboardEvent.charCode (it gives english code, you need to map it to your Georgian keyboard layout.) Key press with shift may give lowercase letter when capslock is on.