Skip to content

Fix sticky keys for thumb shift mode#45

Open
tychiu wants to merge 1 commit intoibus:mainfrom
tychiu:thumb-shift-fix-sticky-keys
Open

Fix sticky keys for thumb shift mode#45
tychiu wants to merge 1 commit intoibus:mainfrom
tychiu:thumb-shift-fix-sticky-keys

Conversation

@tychiu
Copy link

@tychiu tychiu commented Feb 15, 2026

Symptom
Given that:

  • typing method is set to thumb shift mode
  • input mode is not set to any Latin mode
  • a text field is in focus
  • a user has pressed once a key not included in the thumb shift key map, mostly command keys e.g.:
    • Backspace
    • Return (Enter)
    • Delete
    • Arrow Keys

When the user releases the key
Then the user sees that the key is being pressed forever (until esc is pressed or the user switches away from Anthy)

Expected
Given that:

  • typing method is set to thumb shift mode
  • input mode is not set to any Latin mode
  • a text field is in focus
  • a user has pressed once a key not included in the thumb shift key map, mostly command keys e.g.:
    • Backspace
    • Return (Enter)
    • Delete
    • Arrow Keys

When the user releases the key
Then the user sees that the key press does not automatically repeat itself in the text field

Root Cause
For keys that are neither thumb shift keys nor text keys, only the key press is processed. The key release is ignored by __process_key_event_thumb().

For illustration, please compare the if statements between the pressed handling and the released handling in engine/python3/engine.py.

Key Release:

if state & IBus.ModifierTypes.RELEASE_MASK:
    # ... timer logic omitted
    if keyval in [RS(), LS()]:
        # ... omitted
    elif keyval == self._RMM:
        # ... omitted

Key Press:

if state & IBus.ModifierTypes.RELEASE_MASK:
    # ... omitted (quoted above)
else:
    if keyval in [RS(), LS()] and state == 0:
        # ... omitted
    elif keyval in self.__thumb().get_chars() and state == 0:
        # ... omitted
    else:
        # ... timer logic omitted
        if cmd_exec(keyval, state): # <--- processes command key press
            return True
        # ... omitted

Hopefully this comparison is clear enough to show that cmd_exec() does not have a corresponding key release action.

Solution
Steps:

  1. Store every non-thumb-shift, non-text key press
  2. When handling non-thumb-shift, non-text key releases,
    a. fire release for the previous key press (if present)
    b. reset the key press storage
    c. hand the current key release back to IBus

Remarks
Please feel free to let me know about any practice that I should follow for this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant