Skip to main content

Orca

Implements: IScreenReader

An Orca instance can be used to launch and control Orca on Linux.

Here's a typical example using an Orca instance:

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Move to the next item.
await orca.next();

// Stop Orca.
await orca.stop();
})();

Contents:

orca.keyboardCommands​

Getter for the Orca keyboard commands supported by Guidepup.

Use a command with perform to invoke it:

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Move to the next item.
await orca.perform(orca.keyboardCommands.MoveToNextSibling);

// Stop Orca.
await orca.stop();
})();

Each command includes its command name, description, keyboard representation, and Orca service.

See OrcaKeyCodeCommands for the available commands.

Returns: OrcaKeyCodeCommands

orca.name​

Getter for the screen reader name "Orca".

import { orca } from "@guidepup/guidepup";

console.log(orca.name); // "Orca"

Returns: string

orca.version​

Getter for the Orca version.

import { orca } from "@guidepup/guidepup";

console.log(orca.version);

Returns: string

orca.act([options])​

Perform the default action for the item in the Orca cursor.

Equivalent of executing Orca+Control+Enter.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.next();
await orca.act();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.capture(action[, options])​

Capture Orca output produced while an action runs. The action can be performed using an external automation tool such as Playwright. The returned capture contains the action's result and the Orca output associated with the action.

import { test } from "@playwright/test";
import { orca } from "@guidepup/guidepup";

test("capture Orca output while clicking a button", async ({ page }) => {
await orca.start();

const capture = await orca.capture(() =>
page
.getByRole("button", {
name: "Submit",
})
.click(),
);
console.log(capture);

await orca.stop();
});

Parameters:

  • action () => Promise<T> | T The action to perform while capturing Orca output.
  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<Capture<T>> The action's result and captured Orca output.

orca.clearItemTextLog()​

Clear the log of all spoken phrases for this Orca instance.

For Orca this is the same as clearSpokenPhraseLog.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.clearItemTextLog();
await orca.stop();
})();

Returns: Promise<void>

orca.clearSpokenPhraseLog()​

Clear the log of all spoken phrases for this Orca instance.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.clearSpokenPhraseLog();
await orca.stop();
})();

Returns: Promise<void>

orca.click([options])​

Click the mouse.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.click({ button: "left", clickCount: 1 });
await orca.click({ button: "right", clickCount: 2 });
await orca.stop();
})();

Parameters:

Returns: Promise<void>

orca.default()​

Detect whether Orca is the default screen reader for the current OS:

  • false for Windows
  • false for macOS
  • true for Linux

This detects the operating system; it does not check whether Orca is installed.

import { orca } from "@guidepup/guidepup";

console.log(orca.default());

Returns: boolean

orca.detect()​

Detect whether Orca is supported on the current operating system:

  • false for Windows
  • false for macOS
  • true for Linux

This detects the operating system; it does not check whether Orca is installed. start() will fail if Orca is not installed.

import { orca } from "@guidepup/guidepup";

console.log(orca.detect());

Returns: boolean

orca.getSetting(key)​

Returns the value of a setting for this Orca instance.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
console.log(orca.getSetting("/org/gnome/orca/default/speech/enable"));
await orca.stop();
})();

Parameters:

  • key string The setting name.

Returns: unknown The setting value.

orca.getSettings()​

Returns all the current settings for this Orca instance.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
console.log(orca.getSettings());
await orca.stop();
})();

Returns: Record<string, unknown> Current settings values.

orca.interact([options])​

Interact with the item under the Orca cursor.

Equivalent of executing Orca+Control+Down Arrow.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.next();
await orca.interact();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.itemText()​

Get the text of the item in the Orca cursor.

For Orca this is the same as lastSpokenPhrase.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.next();
console.log(await orca.itemText());
await orca.stop();
})();

Returns: Promise<string> The item's text.

orca.itemTextLog()​

Get the log of all visited item text for this Orca instance.

For Orca this is the same as spokenPhraseLog.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
for (let i = 0; i < 10; i++) {
await orca.next();
}
console.log(await orca.itemTextLog());
await orca.stop();
})();

Returns: Promise<Array<string>> The item text log.

orca.lastSpokenPhrase()​

Get the last spoken phrase.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.next();
console.log(await orca.lastSpokenPhrase());
await orca.stop();
})();

Returns: Promise<string> The last spoken phrase.

orca.navigateNextUntil(matcher[, options])​

Move the Orca cursor to the next location until its spoken phrase matches the provided matcher.

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Move to the next item containing the exact spoken phrase.
await orca.navigateNextUntil(/Submit/);

// Stop Orca.
await orca.stop();
})();

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

orca.navigateNextHeadingUntil(matcher[, options])​

Move the Orca cursor to the next heading until its spoken phrase matches the provided matcher.

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Move to the next heading with a matching spoken phrase.
await orca.navigateNextHeadingUntil(/Account/);

// Stop Orca.
await orca.stop();
})();

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

orca.navigateNextLandmarkUntil(matcher[, options])​

Move the Orca cursor to the next landmark until its spoken phrase matches the provided matcher.

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Move to the next landmark with a matching spoken phrase.
await orca.navigateNextLandmarkUntil(/Main/);

// Stop Orca.
await orca.stop();
})();

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

Move the Orca cursor to the next link until its spoken phrase matches the provided matcher.

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Move to the next link with a matching spoken phrase.
await orca.navigateNextLinkUntil(/Home/);

// Stop Orca.
await orca.stop();
})();

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

orca.navigatePreviousUntil(matcher[, options])​

Move the Orca cursor to the previous location until its spoken phrase matches the provided matcher.

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Move to the previous item containing the exact spoken phrase.
await orca.navigatePreviousUntil(/Submit/);

// Stop Orca.
await orca.stop();
})();

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

orca.navigatePreviousHeadingUntil(matcher[, options])​

Move the Orca cursor to the previous heading until its spoken phrase matches the provided matcher.

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Move to the previous heading with a matching spoken phrase.
await orca.navigatePreviousHeadingUntil(/Account/);

// Stop Orca.
await orca.stop();
})();

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

orca.navigatePreviousLandmarkUntil(matcher[, options])​

Move the Orca cursor to the previous landmark until its spoken phrase matches the provided matcher.

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Move to the previous landmark with a matching spoken phrase.
await orca.navigatePreviousLandmarkUntil(/Main/);

// Stop Orca.
await orca.stop();
})();

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

Move the Orca cursor to the previous link until its spoken phrase matches the provided matcher.

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Move to the previous link with a matching spoken phrase.
await orca.navigatePreviousLinkUntil(/Home/);

// Stop Orca.
await orca.stop();
})();

The matcher can be an exact matching string, a regular expression, or a function that returns whether the spoken phrase matches. The command throws if no match is found within maxNavigationAttempts (default is 10). If the last spoken phrase is already a match then no navigation occurs.

Parameters:

Returns: Promise<void>

orca.next([options])​

Move the Orca cursor to the next location.

Equivalent of executing Orca+Control+Right Arrow.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.next();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.nextHeading([options])​

Move the Orca cursor to the next heading.

Equivalent of executing H.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.nextHeading();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.nextLandmark([options])​

Move the Orca cursor to the next landmark.

Equivalent of executing D.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.nextLandmark();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

Move the Orca cursor to the next link.

Equivalent of executing K.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.nextLink();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.perform(command[, options])​

Perform an Orca keyboard command.

The command can be any OrcaKeyCodeCommand exposed through OrcaKeyCodeCommands, available as orca.keyboardCommands or the orcaKeyCodeCommands export.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.perform(orca.keyboardCommands.MoveToNextSibling);
await orca.stop();
})();

Parameters:

  • command OrcaKeyCodeCommand Orca keyboard command.
  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.press(key[, options])​

Press a key on the focused item.

key can specify the intended keyboardEvent.key value or a single character to generate the text for. A superset of the key values can be found on the MDN key values page. Examples of the keys are:

F1 - F20, Digit0 - Digit9, KeyA - KeyZ, Backquote, Minus, Equal, Backslash, Backspace, Tab, Delete, Escape, ArrowDown, End, Enter, Home, Insert, PageDown, PageUp, ArrowRight, ArrowUp, etc.

See LinuxKeyCodes for the full range of available keys.

Following modification shortcuts are also supported: Shift, Control, Alt, Meta.

See LinuxModifiers for the full range of available modifiers.

Holding down Shift will type the text that corresponds to the key in the upper case.

If key is a single character, it is case-sensitive, so the values a and A will generate different respective texts.

Shortcuts such as key: "Control+f" or key: "Control+Shift+f" are supported as well. When specified with the modifier, modifier is pressed and being held while the subsequent key is being pressed.

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Open a find text modal.
await orca.press("Control+f");

// Stop Orca.
await orca.stop();
})();

Parameters:

  • key string Name of the key to press or a character to generate, such as ArrowLeft or a.
  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.previous([options])​

Move the Orca cursor to the previous location.

Equivalent of executing Orca+Control+Left Arrow.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.previous();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.previousHeading([options])​

Move the Orca cursor to the previous heading.

Equivalent of executing Shift+H.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.previousHeading();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.previousLandmark([options])​

Move the Orca cursor to the previous landmark.

Equivalent of executing Shift+D.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.previousLandmark();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

Move the Orca cursor to the previous link.

Equivalent of executing Shift+K.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.previousLink();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.spokenPhraseLog()​

Get the log of all spoken phrases for this Orca instance.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
for (let i = 0; i < 10; i++) {
await orca.next();
}
console.log(await orca.spokenPhraseLog());
await orca.stop();
})();

Returns: Promise<Array<string>> The spoken phrase log.

orca.start([options])​

Turn Orca on. Orca must be installed on Linux.

By default, capture is set to "initial": it captures the first page of output, but not subsequent content. Set capture to true for full capture or false to disable capture.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
// ... perform some commands.
await orca.stop();
})();

Parameters:

  • Optional: options Pick<StartOptions, "capture" | "settings"> Capture and screen reader settings options.

Returns: Promise<void>

orca.stop()​

Turn Orca off.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
// ... perform some commands.
await orca.stop();
})();

Returns: Promise<void>

orca.stopInteracting([options])​

Stop interacting with the current item under the Orca cursor.

Equivalent of executing Orca+Control+Up Arrow.

import { orca } from "@guidepup/guidepup";

(async () => {
await orca.start();
await orca.next();
await orca.stopInteracting();
await orca.stop();
})();

Parameters:

  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>

orca.type(text[, options])​

Type text into the focused item.

To press a special key, like Control or ArrowDown, use orca.press(key[, options]).

Each character is typed separately. As a result, lastSpokenPhrase() returns the phrase for the final character; use spokenPhraseLog() to access output for the complete string.

import { orca } from "@guidepup/guidepup";

(async () => {
// Start Orca.
await orca.start();

// Type a username and key Enter.
await orca.type("my-username");
await orca.press("Enter");

// Stop Orca.
await orca.stop();
})();

Parameters:

  • text string Text to type into the focused item.
  • Optional: options Pick<CommandOptions, "capture"> Capture options.

Returns: Promise<void>