prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Cannot add custom key codes in 3.0

Open
#993 3 comments 2 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.