mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-04-04 08:30:31 +00:00
fix: propagate keyUp and char keyboard events to JS listeners
dispatchKeyEvent only handled keyDown, returning early for keyUp, rawKeyDown, and char types. This meant JS keyup and keypress listeners never fired via CDP. Now keyUp dispatches as "keyup" and char dispatches as "keypress". rawKeyDown remains a no-op (Chrome-internal, not used for JS dispatch). Fixes #2080 Ref #2043
This commit is contained in:
@@ -52,17 +52,19 @@ fn dispatchKeyEvent(cmd: *CDP.Command) !void {
|
||||
|
||||
try cmd.sendResult(null, .{});
|
||||
|
||||
// quickly ignore types we know we don't handle
|
||||
switch (params.type) {
|
||||
.keyUp, .rawKeyDown, .char => return,
|
||||
.keyDown => {},
|
||||
}
|
||||
// rawKeyDown is a Chrome-internal event type not used for JS dispatch
|
||||
if (params.type == .rawKeyDown) return;
|
||||
|
||||
const bc = cmd.browser_context orelse return;
|
||||
const page = bc.session.currentPage() orelse return;
|
||||
|
||||
const KeyboardEvent = @import("../../browser/webapi/event/KeyboardEvent.zig");
|
||||
const keyboard_event = try KeyboardEvent.initTrusted(comptime .wrap("keydown"), .{
|
||||
const keyboard_event = try KeyboardEvent.initTrusted(switch (params.type) {
|
||||
.keyDown => comptime .wrap("keydown"),
|
||||
.keyUp => comptime .wrap("keyup"),
|
||||
.char => comptime .wrap("keypress"),
|
||||
.rawKeyDown => unreachable,
|
||||
}, .{
|
||||
.key = params.key,
|
||||
.code = params.code,
|
||||
.altKey = params.modifiers & 1 == 1,
|
||||
|
||||
Reference in New Issue
Block a user