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 UsKeyboardLayout

From Leeroopedia
Revision as of 11:38, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Microsoft_Playwright_UsKeyboardLayout.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Implementation Page

Overview

UsKeyboardLayout defines the complete US keyboard layout mapping, providing key definitions with key codes, shifted characters, text values, and location information for keyboard input simulation.

Description

This module exports the USKeyboardLayout constant, a comprehensive mapping from key names to KeyDefinition objects. Each definition includes:

  • key -- the key value string
  • keyCode -- the numeric key code
  • shiftKey -- the character produced when Shift is held
  • shiftKeyCode -- optional alternate key code with Shift
  • text -- the text character generated
  • location -- key location (for numpad, left/right modifier keys)

The layout covers function keys, number row, letter keys, punctuation, numpad, modifier keys, and special keys.

Usage

Used by the keyboard input system across all browser implementations to translate key names into key codes and character values.

Code Reference

Source Location

packages/playwright-core/src/server/usKeyboardLayout.ts (155 lines)

Type and Export Signatures

export type KeyDefinition = {
  key: string;
  keyCode: number;
  keyCodeWithoutLocation?: number;
  shiftKey?: string;
  shiftKeyCode?: number;
  text?: string;
  location?: number;
};

export type KeyboardLayout = { [s: string]: KeyDefinition };
export const keypadLocation = 3;
export const USKeyboardLayout: KeyboardLayout;

Import

import { USKeyboardLayout, keypadLocation } from './server/usKeyboardLayout';
import type { KeyDefinition, KeyboardLayout } from './server/usKeyboardLayout';

I/O Contract

Structure

  • Keys: standard key code names (e.g., 'KeyA', 'Digit1', 'Enter', 'NumpadMultiply')
  • Values: KeyDefinition objects with key metadata

Example Entry

'KeyA': { keyCode: 65, key: 'a', shiftKey: 'A' }
'Digit1': { keyCode: 49, shiftKey: '!', key: '1' }

Related Pages

Page Connections

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