如何为特定的键盘命令添加事件处理程序?

huangapple go评论47阅读模式
英文:

How to add an event handler for a specific keyboard command?

问题

有没有一种方法可以订阅或注册事件处理程序来监听 Office 插件中的键盘命令?

我的目标是,当用户使用特定的键盘命令时,例如ctrl+return,我想在文档的末尾添加一个'Hello world'段落。

注意:我正在使用使用 Office JS API 的 JS Word 插件模板。

英文:

Is there a way to subscribe or register an event handler to listen for keyboard commands in office add-ins?

My goal is to insert a paragraph when a user uses a specific keyboard command, for example, on ctrl+return, I would like to add a 'Hello world' paragraph to the end of the document.

Note: I am using the JS word add-in template, which makes use of the Office JS API.

答案1

得分: 1

The Office JavaScript API (OfficeJS) 不提供处理 Office 应用程序中的键盘快捷键的功能,除了 Excel 外。目前,键盘快捷键仅在以下平台和版本上受支持:

  • Windows 上的 Excel:版本 2102(版本号 13801.20632)及更高版本
  • Mac 上的 Excel:16.48 及更高版本
  • Excel 在 Web 上

为 Office 插件添加自定义键盘快捷键文章中详细了解更多信息。您还可以在使用键盘快捷键执行 Office 插件操作示例代码中找到相关信息。

您可以在Tech Community上发布或投票支持现有的功能请求,这些请求将在 Office 开发团队进行规划过程时考虑进来。

英文:

The Office JavaScript API (OfficeJS) doesn't provide anything for handling keyboard shortcuts in Office applications except Excel. Keyboard shortcuts are currently only supported on Excel and only on these platforms and builds:

  • Excel on Windows: Version 2102 (Build 13801.20632) and later
  • Excel on Mac: 16.48 and later
  • Excel on the web

Read more about that in the Add custom keyboard shortcuts to your Office Add-ins article. Also you may find the Use keyboard shortcuts for Office add-in actions sample code.

You can post or vote for an existing feature request on Tech Community where they are considered when the Office dev team goes through the planning process.

huangapple
  • 本文由 发表于 2023年5月29日 11:47:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76354567.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定