Skip to main content

KeyCodeCommand

Extends: object

Object representing a 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],
};

(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:

keyCodeCommand.keyCode

The key code or key codes to send.

Type: any | Array<any&#62

keyCodeCommand.modifiers

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

Type: Array<string&#62