Reputation: 7343
I'm using the PlatformIO package, and I want to override the shortcut that allows me to focus in and out of the embedded terminal. The default shortcut is ctrl + alt + f. I want to change it to esc.
I tried this in my keymap.cson:
'atom-text-editor':
'esc': 'Platformio Ide Terminal: Focus'
I also tried with "escape" instead of "esc", but neither was able to override the default shortcut.
How do I accomplish this?
Upvotes: 4
Views: 542
Reputation: 12882
The correct key for Esc is esc
, but more importantly, you need to use the correct command to focus. The following works, given that the terminal is visible.
'atom-text-editor':
'escape': 'platformio-ide-terminal:focus'
To toggle and focus the terminal in one keystroke, you need to use "composed" commands. In that case, you can put something like the following into your init.coffee
:
atom.commands.add "atom-workspace", "my-custom-toggle": ->
activeEditor = atom.views.getView atom.workspace.getActiveTextEditor()
pioTerminal = document.querySelector(".platformio-ide-terminal.terminal-view")
parentNode = pioTerminal.parentNode if pioTerminal
if !parentNode or parentNode.style.display is "none"
atom.commands.dispatch(activeEditor, "platformio-ide-terminal:toggle")
atom.commands.dispatch(activeEditor, "platformio-ide-terminal:focus")
And then you use that command in your keymap.cson
:
'atom-text-editor':
'escape': 'my-custom-toggle'
Upvotes: 3