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 BidiKeyboard

From Leeroopedia
Knowledge Sources
Domains BiDi, Input
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for mapping Playwright key names to WebDriver BiDi key values provided by the Playwright library.

Description

The `bidiKeyboard` module exports the `getBidiKeyValue` function, which maps human-readable key names (like 'Enter', 'Backspace', 'ArrowLeft', 'F1', etc.) to their corresponding Unicode Private Use Area (PUA) key values as specified by the WebDriver specification. Single-character keys are returned as-is. Special keys are mapped to their Unicode equivalents (e.g., 'Enter' maps to '\uE007', 'Tab' to '\uE004'). The module handles newline characters ('\r', '\n') by mapping them to 'Enter'. This is a third-party module originally from Puppeteer, adapted for Playwright.

Usage

Use BidiKeyboard when translating Playwright's key name representation into BiDi-compatible key values for `input.performActions` commands.

Code Reference

Source Location

  • Repository: Microsoft_Playwright
  • File: packages/playwright-core/src/server/bidi/third_party/bidiKeyboard.ts

Signature

export const getBidiKeyValue = (keyName: string): string;

Import

import { getBidiKeyValue } from '../server/bidi/third_party/bidiKeyboard';

I/O Contract

Inputs

Name Type Required Description
keyName string Yes Playwright key name (e.g., 'Enter', 'ArrowLeft', 'a', 'F1')

Outputs

Name Type Description
value string The BiDi-compatible Unicode key value

Usage Examples

import { getBidiKeyValue } from './third_party/bidiKeyboard';

getBidiKeyValue('Enter');     // '\uE007'
getBidiKeyValue('Tab');       // '\uE004'
getBidiKeyValue('ArrowLeft'); // '\uE012'
getBidiKeyValue('a');         // 'a' (single character returned as-is)
getBidiKeyValue('\n');        // '\uE007' (newline mapped to Enter)

Related Pages

Page Connections

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