Skip to main content

MacOSKeystrokeCommand

Extends: KeystrokeCommand

Object representing a MacOS keystroke command.

For example, use when performing a VoiceOver command:

import { voiceOver, MacOSModifiers } from "@guidepup/guidepup";

const poundSymbolKeystrokeCommand = {
characters: "3",
modifiers: [MacOSModifiers.Alt],
description: "A pound symbol",
representation: "#",
};

(async () => {
// Start VoiceOver.
await voiceOver.start();

// Send a '#' keystroke.
await voiceOver.perform(poundSymbolKeystrokeCommand);

// Stop VoiceOver.
await voiceOver.stop();
})();

Note: the above is slightly contrived as we could just type a # character using:

await voiceOver.type("#");

Contents:

macOSKeystrokeCommand.characters

The character(s) to send.

Type: string

macOSKeystrokeCommand.description

Optional: Description of the action the keystroke performs.

Type: string

macOSKeystrokeCommand.modifiers

Optional: List of modifier keys to press while sending the character(s).

Type: Array<MacOSModifiers>

macOSKeystrokeCommand.representation

Optional: Symbolic representation of the character(s) and modifier keys this command uses.

Type: string