Settable ttimeoutlen for Escape key sequences#1679
Open
rolandwalker wants to merge 1 commit intomainfrom
Open
Conversation
|
Findings
No direct security issues found in this diff. |
Since olden times, most terminals have sent Alt+key combinations, function keys, and so on as sequences of characters starting with Escape. This creates an ambiguity. What if the user simply typed "Escape"? Terminal applications solve this by waiting some period of time before registering a plain "Escape". prompt_toolkit waits a default of 0.5 seconds. This pause can be a nuisance for users who use the Escape key, especially users of vi keybindings. Here we provide access to prompt_toolkit's ttimeoutlen property, making the value independent between Emacs and vi modes. At smaller values, an Escape key alone is recognized much more quickly. The toolbar UI for vi modes may lag on the display of a change in state, but the keystroke is recognized for the typist. The setting is named after the Vim setting for familiarity to the group most likely to need it.
abd1846 to
bdd35d8
Compare
scottnemes
approved these changes
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since olden times, most terminals have sent Alt+key combinations, function keys, and so on as sequences of characters starting with Escape.
This creates an ambiguity. What if the user simply typed "Escape"? Terminal applications solve this by waiting some period of time before registering a plain "Escape". prompt_toolkit waits a default of 0.5 seconds.
This pause can be a nuisance for users who use the Escape key, especially users of vi keybindings.
Here we provide access to prompt_toolkit's
ttimeoutlenproperty, making the value independent between Emacs and vi modes. At smaller values, an Escape key alone is recognized much more quickly. The toolbar UI for vi modes may still lag on the display of a change in state, but the keystroke is recognized for the typist.This could also be used to improve the case of pressing Escape to cancel completions.
The setting is named after the Vim setting for familiarity to the group most likely to need it.
Checklist
changelog.mdfile.AUTHORSfile (or it's already there).