简体   繁体   English

当用户单击Safari扩展程序的工具栏命令时,获取键盘修改器

[英]Get keyboard modifier when user click in toolbar command of safari extension

I want to get keyboard modifiers (like shift or option keys) when user click by toobar command of my safari extension. 当用户通过我的Safari扩展程序的toobar命令单击时,我想获取键盘修饰符(例如Shift或Option键)。

In global HTML page I have next code: 在全局HTML页面中,我有以下代码:

safari.application.addEventListener("command", performCommand, false);

function performCommand(event)
{
    if (event.command === "foo") {

          //TODO: is shift pressed?
    }
}

Is it possible? 可能吗? Or may be exists any workaround? 或可能存在任何解决方法?

Unfortunately, keyCode is not currently available on the command and validate events for toolbar items. 不幸的是,keyCode当前在命令上不可用,并且无法验证工具栏项目的事件。 I submit enhancement request to apple. 我向苹果提交了增强请求。

In Safari, you should be able to do: 在Safari中,您应该可以执行以下操作:

if (event.shiftKey) {
  // Shift key was pressed...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是什么导致Safari发送“命令”事件时未触发Safari扩展(工具栏按钮)? - What could cause a Safari extension (toolbar button) to not trigger when Safari sends the “command” event? 当用户单击工具栏中的扩展名图标时,如何通过webExtension更改文档元素? - How can I change document elements by webExtension when user click on extension icon in toolbar? Safari 2.0 中修饰键的键盘事件 - Keyboard Events for Modifier Keys in Safari 2.0 Safari 应用程序扩展:工具栏弹出 JavaScript 未运行 - Safari App Extension: Toolbar popup JavaScript not running 如何仅在URL满足特定条件时才启用Safari工具栏按钮扩展名(“验证”检查)? - How do I only enable a Safari toolbar button extension when the URL meets certain criteria ('validate' check)? 我的项目是虚拟钢琴我需要当用户单击键盘键钢琴按钮得到 hover 颜色 - my project is virtual piano I need when user click keyboard key the piano button get hover color Chrome扩展键盘命令在弹出窗口打开时触发两次 - Chrome extension keyboard command firing twice when popup is open Safari中点击事件中忽略键盘事件 - Ignore keyboard events within the click event in Safari Safari扩展:将变量从活动选项卡传递到工具栏 - Safari Extension: Passing variable from active tab to toolbar Safari Extension,直接从工具栏访问页面/内容? - Safari Extension, accessing page/content directly from toolbar?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM