Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

04. 快捷键注册-例子 #4

Open
PDKSophia opened this issue Feb 4, 2021 · 0 comments
Open

04. 快捷键注册-例子 #4

PDKSophia opened this issue Feb 4, 2021 · 0 comments
Labels
documentation Improvements or additions to documentation vscode

Comments

@PDKSophia
Copy link
Owner

PDKSophia commented Feb 4, 2021

场景

每次我们都需要 cmd+shift + P 调出选择器,然后输入我们注册的事件名,特别麻烦,vscode 支持快捷键注册,下面看看如何实现吧!

代码展示

   "commands": [
      {
        "command": "beehive.keybindings",
        "title": "demo4: beehive.keybindings !"
      }
    ],
    "keybindings": [
      {
        "command": "beehive.keybindings",
        "key": "Cmd+]",
        "mac": "Cmd+]",
        "when": "editorTextFocus"
      }
    ]

然后此时我们通过 Run Extension ,在本地窗口,我们随便打开一个文件,然后按下 : cmd + ] 就可以触发我们定义的
beehive.keybindings 事件

需注意,因为我们加了 when 属性,这边表示的是当编辑器聚焦时才可以

源码展示

@PDKSophia PDKSophia added documentation Improvements or additions to documentation vscode labels Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation vscode
Projects
None yet
Development

No branches or pull requests

1 participant