pressKey
Presses a single key (optionally with modifiers) using trusted keyboard input, firing the full real key pipeline — keydown → keypress → beforeinput → input → keyup.
It is delivered to the window’s DOM-focused element, so the caller focuses the target first and then awaits the expected effect; the press itself polls for nothing. On mobile the accepted keys are the named ones ('Enter', 'Escape', 'Tab', 'Backspace', 'Delete', the arrows) plus single printable characters — anything else throws rather than pressing nothing.
Import:
import { pressKey } from 'obsidian-dev-utils/obsidian/trusted-input';Signature:
function pressKey(params: PressKeyParams): Promise<void>Parameters:
| Parameter | Type | Description |
|---|---|---|
params | PressKeyParams | The key to press and any modifiers to hold. |
Returns: Promise<void> — A Promise that resolves once the key press has been injected.