KeyEvent rework
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.7k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
This is a tracking issue for redoing `KeyEvent`. Currently there are a number of things wrong with the implementation, which we're seeing as Control-X etc not working except as menu shortcuts (#1030), issues with numpad arrow keys (#318 and a number of related issues and PR's). Issue #357 rolls up a number of the numpad related issues.
I propose to rework `KeyEvent` to fix these. The following goals are in scope:
* Key events should be as consistent as possible across platforms. This especially extends to the text field in keys with modifiers, scan codes, etc.
* Export a reliable way for text widgets to determine whether the key event represents a potential text insertion. This will involve rethinking `is_printable` (see #119 and #1016).
* Detailed information should be available and accurate. This includes tracking both left and right shift, as well as indicating whether the key is a repeat from being held down.
* The Windows implementation should be UTF-16 aware, though key text in the astral plane is probably unlikely (see #174).
* Expected behavior should be documented, including guidance about how and when to interpret keys as text insertion, and recognition of command modifiers.
I propose that we converge as much as possible toward the web [KeyboardEvent](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) mechanism. Note that the [KeyboardEvent.keyCode](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode) field has extensive documentation and is likely a useful reference, though it is officially deprecated.
Also note, the issue of key events intersects in a very profound way with IME (input method editor), which is on our medium to long term roadmap but is unlikely to see work soon. Unfortunately, IME is the correct way to get important features such as "dead key" for Latin accents. In general, it's the goal of this work to not interfere with future development of IME, though I will take a look at whether there might be stopgap measures to get some of that functionality if well supported by the platform.
Contributor guide
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
Begin with the existing KeyEvent implementation and the linked reports (#1030, #318, #357, #119, #1016, and #174), then compare the behavior with the referenced web KeyboardEvent documentation. Done means consistent cross-platform key handling, reliable text-insertion detection, accurate modifier and repeat details, UTF-16-aware Windows behavior, and documented expectations without blocking future IME work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100