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 FfInput

From Leeroopedia

Template:Implementation Page

Overview

FfInput provides the raw keyboard, mouse, and touchscreen input implementations for Firefox browser automation, translating Playwright input actions into Firefox-specific protocol commands.

Description

This module contains three input implementation classes for Firefox:

  • RawKeyboardImpl -- translates keyboard events (keydown, keyup) into Firefox Page.dispatchKeyEvent commands with proper key codes and modifiers
  • RawMouseImpl -- translates mouse actions (move, click, wheel) into Firefox Page.dispatchMouseEvent and Page.dispatchWheelEvent commands
  • RawTouchscreenImpl -- translates touch events into Firefox Page.dispatchTouchEvent commands

Helper functions convert Playwright modifier sets and button types to Firefox-specific bitmasks.

Usage

These classes are instantiated internally by the Firefox page implementation and are not used directly by end users.

Code Reference

Source Location

packages/playwright-core/src/server/firefox/ffInput.ts (173 lines)

Class Signatures

export class RawKeyboardImpl implements input.RawKeyboard {
  constructor(client: FFSession)
  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(client: FFSession)
  move(x: number, y: number, button: types.MouseButton | 'none', ...): Promise<void>
  down(x: number, y: number, button: types.MouseButton, ...): Promise<void>
  up(x: number, y: number, button: types.MouseButton, ...): Promise<void>
  wheel(x: number, y: number, buttons: Set<types.MouseButton>, ...): Promise<void>
}

export class RawTouchscreenImpl implements input.RawTouchscreen {
  constructor(client: FFSession)
  tap(x: number, y: number, modifiers: Set<types.KeyboardModifier>): Promise<void>
}

Import

import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './server/firefox/ffInput';

I/O Contract

Inputs

  • Keyboard: key codes, modifiers, key text, auto-repeat status
  • Mouse: coordinates, buttons, modifier sets, click counts
  • Touch: coordinates and modifier sets

Outputs

  • Firefox protocol messages dispatched via FFSession.send()

Helper Functions

  • toModifiersMask(modifiers) -- converts modifier set to bitmask (Alt=1, Control=2, Shift=4, Meta=8)
  • toButtonNumber(button) -- converts button name to number (left=0, middle=1, right=2)
  • toButtonsMask(buttons) -- converts button set to bitmask

Related Pages

Page Connections

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