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
- orca.name
- orca.version
- orca.act([options])
- orca.capture(action[, options])
- orca.clearItemTextLog()
- orca.clearSpokenPhraseLog()
- orca.click([options])
- orca.default()
- orca.detect()
- orca.getSetting(key)
- orca.getSettings()
- orca.interact([options])
- orca.itemText()
- orca.itemTextLog()
- orca.lastSpokenPhrase()
- orca.navigateNextUntil(matcher[, options])
- orca.navigateNextHeadingUntil(matcher[, options])
- orca.navigateNextLandmarkUntil(matcher[, options])
- orca.navigateNextLinkUntil(matcher[, options])
- orca.navigatePreviousUntil(matcher[, options])
- orca.navigatePreviousHeadingUntil(matcher[, options])
- orca.navigatePreviousLandmarkUntil(matcher[, options])
- orca.navigatePreviousLinkUntil(matcher[, options])
- orca.next([options])
- orca.nextHeading([options])
- orca.nextLandmark([options])
- orca.nextLink([options])
- orca.perform(command[, options])
- orca.press(key[, options])
- orca.previous([options])
- orca.previousHeading([options])
- orca.previousLandmark([options])
- orca.previousLink([options])
- orca.spokenPhraseLog()
- orca.start([options])
- orca.stop()
- orca.stopInteracting([options])
- orca.type(text[, options])
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:
optionsPick<CommandOptions, "capture">Capture options.
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:
optionsPick<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();
})();
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();
})();
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:
- Optional:
optionsClickOptions Click options.
orca.default()
Detect whether Orca is the default screen reader for the current OS:
falsefor Windowsfalsefor macOStruefor 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:
falsefor Windowsfalsefor macOStruefor 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:
keystring 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:
optionsPick<CommandOptions, "capture">Capture options.
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:
matcherSpokenPhraseMatcher Matcher to navigate until reached.- Optional:
optionsNavigateOptions Additional options.
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:
matcherSpokenPhraseMatcher Matcher to navigate until reached.- Optional:
optionsNavigateOptions Additional options.
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:
matcherSpokenPhraseMatcher Matcher to navigate until reached.- Optional:
optionsNavigateOptions Additional options.
orca.navigateNextLinkUntil(matcher[, options])
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:
matcherSpokenPhraseMatcher Matcher to navigate until reached.- Optional:
optionsNavigateOptions Additional options.
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:
matcherSpokenPhraseMatcher Matcher to navigate until reached.- Optional:
optionsNavigateOptions Additional options.
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:
matcherSpokenPhraseMatcher Matcher to navigate until reached.- Optional:
optionsNavigateOptions Additional options.
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:
matcherSpokenPhraseMatcher Matcher to navigate until reached.- Optional:
optionsNavigateOptions Additional options.
orca.navigatePreviousLinkUntil(matcher[, options])
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:
matcherSpokenPhraseMatcher Matcher to navigate until reached.- Optional:
optionsNavigateOptions Additional options.
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:
optionsPick<CommandOptions, "capture">Capture options.
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:
optionsPick<CommandOptions, "capture">Capture options.
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:
optionsPick<CommandOptions, "capture">Capture options.
orca.nextLink([options])
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:
optionsPick<CommandOptions, "capture">Capture options.
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:
commandOrcaKeyCodeCommandOrca keyboard command.- Optional:
optionsPick<CommandOptions, "capture">Capture options.
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:
keystring Name of the key to press or a character to generate, such as ArrowLeft or a.- Optional:
optionsPick<CommandOptions, "capture">Capture options.
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:
optionsPick<CommandOptions, "capture">Capture options.
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:
optionsPick<CommandOptions, "capture">Capture options.
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:
optionsPick<CommandOptions, "capture">Capture options.
orca.previousLink([options])
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:
optionsPick<CommandOptions, "capture">Capture options.
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:
optionsPick<StartOptions, "capture" | "settings">Capture and screen reader settings options.
orca.stop()
Turn Orca off.
import { orca } from "@guidepup/guidepup";
(async () => {
await orca.start();
// ... perform some commands.
await orca.stop();
})();
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:
optionsPick<CommandOptions, "capture">Capture options.
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:
textstring Text to type into the focused item.- Optional:
optionsPick<CommandOptions, "capture">Capture options.