Implementation:Microsoft Playwright MacEditingCommands
Overview
MacEditingCommands defines a mapping from keyboard shortcuts to macOS editing commands, used by the WebKit input implementation to translate key combinations into native editing actions.
Description
This module exports a single constant object macEditingCommands that maps keyboard shortcut strings (e.g., 'Control+KeyA') to macOS NSResponder editing command selectors (e.g., 'moveToBeginningOfParagraph:'). The mapping covers standard editing commands including cursor movement, text selection, deletion, clipboard operations, and text formatting.
Key categories include:
- Basic navigation: arrow keys, home/end, page up/down
- Shift+key combinations for selection modification
- Control+key combinations for paragraph-level editing
- Meta (Command) key combinations for document-level operations and clipboard
- Combined modifier shortcuts
Usage
Referenced by the WebKit keyboard input implementation to determine which editing commands to send along with key events on macOS.
Code Reference
Source Location
packages/playwright-core/src/server/macEditingCommands.ts (134 lines)
Export Signature
export const macEditingCommands: { [key: string]: string | string[] };
Import
import { macEditingCommands } from './server/macEditingCommands';
I/O Contract
Inputs
- Key combination strings in format
'Modifier+KeyCode'(e.g.,'Meta+KeyC')
Outputs
- macOS editing command strings (e.g.,
'copy:','moveToBeginningOfDocument:') - Some entries return arrays for multiple commands
Usage Examples
Looking Up a Command
const command = macEditingCommands['Meta+KeyC']; // 'copy:'
const commands = macEditingCommands['Meta+Shift+ArrowUp']; // selection command
Related Pages
- Microsoft_Playwright_WkInput -- WebKit input using mac editing commands
- Microsoft_Playwright_UsKeyboardLayout -- US keyboard layout definitions