Make keyboard shortcut inactive when text input is focused

15 Views Asked by At

I'd like to set a keyboard shortcut for creating a new file to just "n" when a file tree is visible. I added a new keyboard shortcut for explorer.newFile and set the when clause to filesExplorerFocus && !treeFindOpen (the second term is to disable the shortcut when I search inside the explorer with CTRL + F).

The problem is that now I can't use letter "n" to name the file, because this retriggers the shortcut. I know, that I should add just another "when" clause, but I can't figure out what is it.

Do you know which clause is responsible for state when "text input is active in the file explorer" or any similar state that could solve my issue. Or maybe you know a more generic way to find out what I need?

1

There are 1 best solutions below

1
Mark On BEST ANSWER

This seems to work:

{
  "key": "n",
  "command": "explorer.newFile",
  "when": "filesExplorerFocus && !treeFindOpen && !inputFocus"
}