prompt-toolkit / prompt-toolkit/python-prompt-toolkit
How to make a keybinding conditioned on the previous key
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
I want to make it so that when I up arrow + Enter, the selection always executes, regardless of whether or not I am in multiline. My first thought was to create a binding for (Keys.Up, Keys.Enter), but this causes Up to not "evaluate" until I press another key.
Is there some way in my Enter keybinding to check if Up was the previous key (or, really, if history_backward was the most recent thing to be called on the buffer)?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the keybinding handling around Keys.Up and Enter, then trace how history_backward is invoked on the buffer. Determine whether the existing key-sequence behavior can expose the previous action to an Enter binding. Done means a documented, tested way to make Up followed by Enter execute the selection regardless of multiline mode.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100