无论如何,flex 中是否有轮询键盘?
我想知道在 AIR(桌面)应用程序启动时是否按住了某个键,并且我想知道是否按下了某个特定键(在本例中为 ALT)被压制。不幸的是,flex 似乎是基于事件的,以至于无法直接轮询键盘。任何人都可以验证这一点吗?
我知道可以获取键盘事件并手动跟踪。但是,如果用户在启动前按下该键,这将不起作用,因此这不是我的特定问题的解决方案。
I'd like to tell if a certain key is being held down around the startup of my AIR (desktop) application, and I'd like to tell if a specific key (ALT in this case) is being held down. Unfortunately, flex seems to be so event based that there is no way poll the keyboard directly. Can anyone verify this?
I know that it's possible to take the keyboard events and keep track manually. However, this won't work if the user presses the key right before startup, so it isn't a solution for my specific problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我的应用程序中,我通过监听阶段 MOUSE_MOVE、MOUSE_DOWN 和 KEY_DOWN 跟踪按下的 ctrl 操作。 MouseEvent 具有 ctrlKey 和 altKey 属性。我将状态存储在一些静态变量中。当我不再需要这个时,我会取消订阅这些活动。
In my app I track ctrl pressed via listening stage MOUSE_MOVE, MOUSE_DOWN and KEY_DOWN. MouseEvent has ctrlKey and altKey properties. I store state in some static variable . When I longer need this I unsubscribe from these events.
如果您聆听按键抬起的声音,那么如果按键按下,您应该听到此消息。因此,您实际上不会在启动时知道正确的情况,而是在他们释放密钥时知道。您可以在您确定的“启动后”的某个时刻取消订阅该事件。
If you listen for key up, then you should hear this if the key was down. So you won't actually know right at startup, but when they release the key. You can unsubscribe from that event at some point that you determine is "after startup."