Implementation:Microsoft Playwright WkInput
Overview
WkInput provides the raw keyboard, mouse, and touchscreen input implementations for WebKit browser automation, translating Playwright input actions into WebKit Inspector Protocol commands.
Description
This module contains three input implementation classes for WebKit:
RawKeyboardImpl-- translates keyboard events into WebKitInput.dispatchKeyEventcommands with macOS editing command supportRawMouseImpl-- translates mouse actions into WebKitInput.dispatchMouseEventcommands through the page proxy sessionRawTouchscreenImpl-- translates touch events into WebKitInput.dispatchTapEventcommands
A unique aspect of the WebKit implementation is the integration with macEditingCommands for keyboard events, and the use of separate page proxy sessions for mouse events.
Usage
Created internally by the WebKit page implementation. Not used directly by end users.
Code Reference
Source Location
packages/playwright-core/src/server/webkit/wkInput.ts (189 lines)
Class Signatures
export class RawKeyboardImpl implements input.RawKeyboard {
constructor(session: WKSession)
setSession(session: WKSession): void
keydown(modifiers: Set<types.KeyboardModifier>, code: string, keyCode: number, ...): Promise<void>
keyup(modifiers: Set<types.KeyboardModifier>, code: string, keyCode: number, ...): Promise<void>
}
export class RawMouseImpl implements input.RawMouse {
constructor(page: Page)
setSession(session: WKSession): void
move(x: number, y: number, ...): Promise<void>
down(x: number, y: number, ...): Promise<void>
up(x: number, y: number, ...): Promise<void>
}
export class RawTouchscreenImpl implements input.RawTouchscreen {
constructor(page: Page)
}
Import
import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './server/webkit/wkInput';
I/O Contract
Inputs
- Keyboard: key codes, modifiers, key text, with macOS editing command resolution
- Mouse: coordinates, buttons, modifier sets
- Touch: coordinates and modifiers
Outputs
- WebKit Inspector Protocol messages via
WKSession.send()
Related Pages
- Implementation:Microsoft_Playwright_WkConnection -- WebKit session management
- Implementation:Microsoft_Playwright_FfInput -- Firefox equivalent
- Implementation:Microsoft_Playwright_MacEditingCommands -- macOS editing commands used by keyboard
- Implementation:Microsoft_Playwright_UsKeyboardLayout -- Keyboard layout definitions