# gpui_web: Only prevent default for keyboard events the app handled \(\#60889\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 5d447d4223f8455db4811ed332c4ad744bb13e40

Requested commit: 5d447d4223f8455db4811ed332c4ad744bb13e40

Commit: 5d447d4223f8455db4811ed332c4ad744bb13e40

Tree: b48826938bbd7649ce4e7faf31737188397ad601

Author: Baris Palaska

Committer: GitHub

## Message

```
gpui_web: Only prevent default for keyboard events the app handled (#60889)

# Objective

The web platform called `event.preventDefault()` unconditionally before
dispatching every keydown and keyup, destroying all browser defaults
(reload, zoom, tab search, find, address bar) whether or not the app
used the key. The dispatch result already carries the answer:
`!propagate` means a keybinding matched or a handler consumed the
keystroke in the current focus context.


## Solution

Prevent the default only when the app consumed the keystroke, when the
printable character was inserted into the input handler, or mid-IME
composition. Unbound chords now fall through to the browser, and the
behavior is focus-aware: a chord bound in an editor is consumed there
but keeps its browser default when nothing that binds it is focused.


## Testing

Tested locally.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
```

## Parents

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

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