Repository navigation
Conversation
Contributor
|
@osrjv is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
keydown and keyup sent only `key` to Input.dispatchKeyEvent, so pages reading event.code or event.keyCode saw "" and 0 for held keys. They now look the key up with named_key_info like press does, and send code, windowsVirtualKeyCode, location and (on keyDown for printable keys) text. named_key_info now maps the modifier keys to real physical codes (Shift -> ShiftLeft/16, Control -> ControlLeft/17, Alt -> AltLeft/18, Meta -> MetaLeft/91, plus the Right variants) and accepts code-style names (KeyW, Digit1). A modifier's keyDown carries its own bit, so `keydown Shift` and `press Shift` report shiftKey true. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
osrjv
force-pushed
the
fix/keydown-keyup-code-keycode
branch
from
November 10, 2026 13:15
bed4805 to
89fb7fa
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
keydownandkeyupsent onlykeytoInput.dispatchKeyEvent, so pages sawcode == ""andkeyCode == 0for held keys. Games, canvas apps and shortcut libraries that readevent.codecould not be driven with held keys, andpresscan't hold one.keydownon a letter also typed nothing into a focused field.press Shiftwas broken too:named_key_infohad no modifier entries, so it sent the invalid code"Shift", which Chrome drops.keydownandkeyupnow look the key up withnamed_key_infolikepressdoes, and sendcode,windowsVirtualKeyCodeandlocation, plustexton keyDown for printable keys.named_key_infomaps Shift, Control, Alt and Meta to their left-hand keys (ShiftLeft/16,ControlLeft/17,AltLeft/18,MetaLeft/91), accepts the...Rightvariants, and accepts code-style names (KeyA-KeyZ,Digit0-Digit9) as Playwright does. A modifier's keyDown sets its own bit, sokeydown Shiftandpress ShiftreportshiftKey: true. The keydown/keyup path does not sendnativeVirtualKeyCode(#2053);pressis left to #2112.Behavior change: a held printable key now types into the focused field, and a held ArrowUp moves the caret, as on a real keyboard and with Playwright's
keyboard.down.Repro
Before (0.38.1, same code on
main)After
value=dwbecause ArrowUp moved the caret to the start beforepress d.Tested
e2e_keydown_keyup_send_code_and_key_codechecks the full event log (key,code,keyCode,location,shiftKey) and the input value forkeydown/keyuponw, Shift,KeyDand ArrowUp, pluspress Shift. It fails onmainwithcode ""andkeyCode 0and passes here (headless Chrome 156, macOS).named_key_info(modifiers, code-style names, near misses), the modifier bit, and the exactInput.dispatchKeyEventparams forkeydown/keyup, which pins the missingnativeVirtualKeyCode.cargo test: 1,471 unit and 23 CLI integration tests pass.cargo fmt -- --checkandcargo clippy -- -D warningsare clean.cargo test --profile ci e2e -- --ignored --test-threads=1with ffmpeg and Obscura v0.2.4: 156 passed, 0 failed. The other 4 ignored tests pass too.pnpm --filter docs test,type-check,buildandtest:routespass.Docs:
--help, README, the core skill and its commands reference, and the Commands docs page. MCPkeydown/keyupdelegate to the CLI command; their key description drops theControl+aexample, since these commands don't parse chords.Related
named_key_info("Control"), so it needs the modifier entries added here. It also adds adispatch_key_eventhelper; whichever PR lands second should merge it with the keydown/keyup helper here.keydownto later mouse commands and toucheshandle_keydown/handle_keyup.nativeVirtualKeyCodefrompress(press on macOS leaves the page in a keydown flood (nativeVirtualKeyCode is set to the Windows key code) #2053). The keydown/keyup path here already omits it.