prompt-toolkit / prompt-toolkit/python-prompt-toolkit
Cannot add custom key codes in 3.0
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
It looks like 3.0 changed the Keys object to an Enum subclass. This makes it impossible to add new key sequences to it dynamically, as the Enum values are determined at class creation time. I have been doing this as described in https://github.com/prompt-toolkit/python-prompt-toolkit/issues/892.
I don't know if there's an easy way to enable this while keeping it an Enum. I would suggest reverting that change. Having an official API to add custom key sequences would be nice as well, although doing it manually isn't a huge deal right now.
As per https://github.com/prompt-toolkit/python-prompt-toolkit/issues/892, it would obviously be good to have some of the more esoteric codes built in so that you don't have to do this. But I think even with fuller coverage the ability to add custom codes is something that should be supported.
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 reviewing the 3.0 change that made the Keys object an Enum subclass and the custom key-sequence approach described in issue #892. Done means users can officially add custom key codes or sequences without relying on manual changes, with behavior covering the requested esoteric codes.
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
- Mostly clear
- Newbie friendliness
- 35/100