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

Disable "Escape Hatch" #758

Closed
marcoklein opened this issue Mar 1, 2022 · 4 comments
Closed

Disable "Escape Hatch" #758

marcoklein opened this issue Mar 1, 2022 · 4 comments

Comments

@marcoklein
Copy link

marcoklein commented Mar 1, 2022

I am using the VIM extension with code mirror that requires lots of Escape inputs. As I use the VIM plugin in conjunction with TAB to insert spaces at the start of a line I often run into the issue that the view looses focus because ESC + TAB is pressed frequently.

Therefore, I want to disable the Escape hatch but find nothing in the documentation at https://codemirror.net/6/docs/ref/.

Is it possible to disable the escape hatch?

@marcoklein marcoklein changed the title Disable "Escape Hatch Disable "Escape Hatch" Mar 1, 2022
@marijnh
Copy link
Member

marijnh commented Mar 2, 2022

There isn't, and that is kind of by design—you really need to have some way to let keyboard-only users move out of the editor. Do you have some other solution for that?

@marcoklein
Copy link
Author

Okay I understand that it's about solving the keyboard trap issue.
I see two approaches:

  1. Allow the escape hatch to be disabled. Then it's the developers responsibility to fullfill the keyboard trap requirement and not the one of CodeMirror6. However, per standard CM6 adheres to the w3 specification.
  2. Allow a configuration of the escape hatch, so one could change it to another shortcut like hold ESC + TAB

What do you think about that?

@thomas992
Copy link

commands/src/commands.ts search for Escape it will be assigned to simplifySelection, you can comment it out
//{key: "Escape", run: simplifySelection}, I think ESC + tab would be "Tab-Escape." To configure this you could replace the "Tab-Escape" value with a variable.

marijnh added a commit to codemirror/view that referenced this issue Mar 21, 2022
FIX: To avoid interfering with things like a vim mode too much, the editor
will now only activate the tab-to-move-focus escape hatch after an escape
press that wasn't handled by an event handler.

Issue codemirror/dev#758
@marijnh
Copy link
Member

marijnh commented Mar 21, 2022

Attached patch changes the behavior to only let tab presses through after an escape press that wasn't handled by the editor's event handlers. This unfortunately opens new opportunities for people with blanket esc handlers to screw this up, but it should help a lot with your use case (assuming esc is let through unmolested in command mode -- is it?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants