Skip to main content

MacOSKeyCodeCommand

Extends: KeyCodeCommand

Object representing a MacOS key code command.

For example, use when performing a VoiceOver command:

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

const moveToNextKeyCodeCommand = {
keyCode: MacOSKeyCodes.ArrowRight,
modifiers: [MacOSModifiers.Control, MacOSModifiers.Option],
description: "Move to next",
representation: "VO-Right Arrow",
};

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

// Move to the next item.
await voiceOver.perform(moveToNextKeyCodeCommand);

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

Note: Guidepup provides a number of utility key codes meaning you shouldn't need to construct your own too often! For example, see VoiceOverKeyCodeCommands for all VoiceOver key codes.

The above example is also slightly contrived as we could just use the convenience method for moving to the next item!

await voiceOver.next();

See also:

Contents:

macOSKeyCodeCommand.description

Optional: Description of the action the key code performs.

Type: string

macOSKeyCodeCommand.keyCode

The key code or key codes to send. See MacOSKeyCodes for available key codes.

Type: number | Array<number>

macOSKeyCodeCommand.modifiers

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

Type: Array<MacOSModifiers>

macOSKeyCodeCommand.representation

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

Type: string