Shortcut mode starting with ESC

I am looking for a general idea of how to go about implementing a shortcut mode where you press ESC and then another key to trigger a function. I currently see that ESC is used as a trigger to switch between indent and focus change.

I assume that would be a custom extension but not sure how to go about what ESC is currently already doing. My though process is once ESC is pressed disable the editor and listen for the next key to perform the shortcut.

Any pointers would be greatly appreciated.

You can use multi-stroke key bindings for something like this, but I don’t recommend using escape for this purpose because, indeed, it’ll mess with the tab handling.

Is there a good way to create a binding for escape that doesn’t mess with the tab handling? Or to selectively handle escape based on some editor state?

You could provide another way to move focus out of the editor. Or, if your esc binding only applies in certain situations, it will be usable with tab in cases where your handler returns false.