events - ActionScript 模拟键盘按下

标签 events actionscript keyboard simulate

我正在尝试模拟按下 TAB 键。我搜索了很长一段时间,没有找到答案。

我尝试过:

dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN, true, false, Keyboard.TAB, 0, 0, false, false, false);

但是什么也没发生..

关于我做错了什么的任何提示吗?如何模拟键盘按下?

最佳答案

You can't completely recreate a key being pressed since that is all user input and not programmatic. However, a program reacts (mostly) to user input through events. By invoking an event through dispatchEvent you are (mostly) recreating what would happen if that event originated through user input.

source .

你想实现什么目标? 将焦点转移到 UI 元素上? Then check this .

插入制表符空格? Then check this out .

关于events - ActionScript 模拟键盘按下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11449555/

相关文章:

delphi - 为什么左 ctrl 不触发 ssLeft?

delphi - 我的 delphi 应用程序与 native 键盘不兼容。我该怎么办?

ios - 出现iOS键盘时如何向上移动 View ?

C++:GetKeyState() 必须运行一次

javascript - subview 更改事件未触发

c# - MouseWheel 事件不以 120 为增量滚动

node.js - 什么时候使用线程池?

actionscript-3 - 网络录制的视频未在 ipad 中播放

flash - 我想创建一些东西来记录用户的音频,然后允许他们将其发送到电子邮件,或将其保存到服务器

apache-flex - Flex textarea 控件未正确更新