# gpui: Fix keystroke interception for standalone modifiers \(\#64537\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/ba42ab9d9851f82a7d8f5ae40b941bf5c515fc10)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: ba42ab9d9851f82a7d8f5ae40b941bf5c515fc10

Requested commit: ba42ab9d9851f82a7d8f5ae40b941bf5c515fc10

Commit: ba42ab9d9851f82a7d8f5ae40b941bf5c515fc10

Tree: 52536e6acb24e225df273067c03962e65ff9641a

Author: Smit Barmase

Committer: GitHub

## Message

````
gpui: Fix keystroke interception for standalone modifiers (#64537)

I ran into this while working on keybindings for the pending-keystrokes
indicator. Keystroke interceptors never received standalone modifiers.

GPUI recognizes a standalone modifier on release through a
`ModifiersChangedEvent`. But interception only handled `KeyDownEvent`s,
so the stroke went straight to keymap dispatch. This change passes the
recognized keystroke to interceptors instead of checking the raw event
type.

1. Recording standalone modifiers

With this binding in `keymap.json`, start recording a binding, then
press and release Shift:

```json
[
  {
    "bindings": {
      "shift": "command_palette::Toggle"
    }
  }
]
```

- Before, the command palette opens and Shift is not recorded.
- After, the recorder captures `shift` without opening the command
palette.

2. Searching for standalone modifiers

With these bindings, enable keystroke search, turn exact matching off,
then press and release Control:

```json
[
  {
    "context": "Editor",
    "bindings": {
      "ctrl": "command_palette::Toggle",
      "ctrl-k": "command_palette::Toggle"
    }
  }
]
```

- Before, holding Control finds Ctrl-K but not Control alone. Releasing
Control clears the modifier query.
- After, releasing Control records it as a standalone key, and non-exact
search finds both Ctrl-K and Control alone.

Release Notes:

- Fixed recording and searching for standalone modifier-key bindings in
the keymap editor.
- [GPUI] Fixed keystroke interceptors to receive standalone modifier
keystrokes.
````

## Parents

- [5299a14401fdcf82a11d2af8117af1d77ef68441](https://git.cafe/gitcafe/zed/commit/5299a14401fdcf82a11d2af8117af1d77ef68441?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/ba42ab9d9851f82a7d8f5ae40b941bf5c515fc10?format=markdown)
