Skip to content

PressKeyParams

Parameters for Lib.pressKey.

Import:

import type { PressKeyParams } from 'obsidian-integration-testing';

Signature:

export interface PressKeyParams

Properties

PropertyTypeDescription
keystringThe key to press, given as an Electron Accelerator key name — e.g. 'Enter', 'Escape', 'Tab', 'Backspace', 'Delete', an arrow key ('Up' / 'Down' / 'Left' / 'Right'), or a printable character ('a', '1'). The produced character (when the key inserts text) is the literal key value; case-correct text belongs to Lib.typeIntoEditor, not a key-press primitive.
modifiers?readonly Modifier[]The modifier keys to hold while the key is pressed, using Obsidian's Modifier names (the same values as an Obsidian Hotkey). 'Mod' resolves per-platform (Cmd on macOS, Ctrl elsewhere); each is mapped to Electron's lowercase sendInputEvent modifier name.
window?WindowThe Obsidian window to press the key in: the main window or a popout. Pass the window that owns the focused target, e.g. leaf.view.containerEl.win for a popout leaf. Each Obsidian window is its own Electron web contents, so the key goes to the DOM-focused element of the window named here, whichever window the OS has focused, and never reaches another window.

**On mobile** there are no popouts, so any window but the main one throws.

Links to this page: