如何检测 CTRL + Flex 中的 C 输入和 F3 键输入
我正在尝试在我的应用程序中实现查找功能,为此我正在尝试基于 F3 或 CTRL + F 等键盘输入打开查找弹出窗口。但是在 F3 上,它不会转到事件侦听器,而是打开默认的查找工具栏而是使用 Internet Explorer。有什么线索,我如何绕过它并在我的应用程序中使用 f3 ?
另一件事是如何在 Flex 中捕获 CTRL + F?
private function keyPressed(evt:KeyboardEvent):void
{
if (evt.keyCode == Keyboard.F3)
{
//open popup
} else {
//do something elese
}
}
谢谢。
I am trying to implement find functionality in my application and for this I am trying to open a find popup based on keyboard inputs like F3 or CTRL + F. But on F3, instead of going to event listener, it opens up the default find toolbar of the Internet Explorer instead. Any clues, how I could bypass it and use f3 in my application?
Another thing is how do I capture CTRL + F in flex?
private function keyPressed(evt:KeyboardEvent):void
{
if (evt.keyCode == Keyboard.F3)
{
//open popup
} else {
//do something elese
}
}
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
用于检测 CTRL + F:
其中“事件”当然是 KeyBoardEvent。
至于F3问题:只要Flash应用程序具有焦点,您编写的代码就可以工作。 F3 键命令也不会被路由到浏览器。因此,您需要做的是确保当用户按 F3 时您的应用程序获得焦点。如何解决这个问题取决于您的 JavaScript 实现。
您可以使用ExternalInterface 告诉浏览器应用程序已准备就绪,然后将注意力集中在应用程序上。或者在 Javascript 中,您可以捕获键盘事件,阻止其默认行为,然后调用 Flash 应用程序上的函数(再次通过ExternalInterface)。
为了帮助您入门,这里有一个用于防止默认 F3 行为的 JQuery 片段:
For detecting CTRL + F:
where 'event' is of course a KeyBoardEvent.
As for the F3 question: the code you wrote will work as long as the flash application has focus. The F3 key command will then also not be routed to the browser. So what you need to do, is make sure that your application has focus when the user hits F3. How you solve this will depend on your JavaScript implementation.
You could use ExternalInterface to tell the browser that the app is ready and than focus on the app. Or in Javascript you could catch the keyboard event, prevent its default behavior, and then call the function on the Flash app (again through ExternalInterface).
To get you started, here's a little JQuery snippet for preventing the default F3 behaviour:
这是对你的第二个问题的回应,顺便说一句,这个问题可能应该在一个完全独立的问题中提出。
该解决方案将允许您测试所需数量的按键组合。它将按下的键存储在数组中,并再次测试该数组以确定组合。
This is in response to your second question, which by the way, should probably be asked in a completely separate question.
This solution will allow you to test for as many key combinations as you need. It stores the pressed keys in an array and tests agains the array to determine combinations.
刚刚检查了所有浏览器(所有浏览器都是最新的)。带有 10.3 flash 播放器。
Chrome / FireFox / Opera 上一切正常。您需要做的主要事情是确保您的注意力集中在 Flash 影片 ( swf ) 上,而不是浏览器 ( HTML ) 或其他地方。
由于IE使用了ActiveX技术,它首先捕获所有的功能键事件给自己,然后解析到Flash中。
野生动物园也是如此。
但您可以在所有浏览器上使用 F2、F8 和 F9。
并获得 ctrl / alt / shift 的组合。
KeyboardEvent 有一些很好的属性:
http://livedocs.adobe.com/flash/9.0 /ActionScriptLangRefV3/flash/events/KeyboardEvent.html#propertySummary
Just checked on all of the browsers ( all are up to date ). with 10.3 flash player.
Everything is working on Chrome / FireFox / Opera. The main thing you need to do is to make sure you have the focus on the flash movie ( swf ), but not on the browser ( HTML ) or somehwere else.
Since IE is using the ActiveX technology, it catches all of the Function keys event to it self first, and then parsing it to the Flash.
Same thing on safari.
But you can use F2, F8 and F9 on All browsers.
And for getting the combination of ctrl / alt / shift.
KeyboardEvent has some nice properties:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/KeyboardEvent.html#propertySummary