Skip to content

clickElement

Clicks the center of an element using trusted input — Electron’s sendInputEvent on desktop, a CDP touch tap in the WebView on mobile.

The element-relative counterpart of clickMouse, mirroring the moveMouse / hoverElement split. Use clickMouse directly when the point to click is not the element’s center — the markdown editor’s margin, for instance, lies inside cm.scrollDOM but outside .cm-sizer, so no element’s center lands on it.

Import:

import { clickElement } from 'obsidian-dev-utils/obsidian/trusted-input';

Signature:

function clickElement(params: ClickElementParams): Promise<void>

Parameters:

ParameterTypeDescription
paramsClickElementParamsThe element to click, the button to press and any modifiers to hold.

Returns: Promise<void> — A Promise that resolves once the click has been injected.


Links to this page: