Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright WkInput

From Leeroopedia

Template:Implementation Page

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 WebKit Input.dispatchKeyEvent commands with macOS editing command support
  • RawMouseImpl -- translates mouse actions into WebKit Input.dispatchMouseEvent commands through the page proxy session
  • RawTouchscreenImpl -- translates touch events into WebKit Input.dispatchTapEvent commands

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

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment