Skip to main content
Scripts are methods that execute in response to user input (gestures). NVDA’s script system provides a powerful way to bind keyboard shortcuts, braille display buttons, and other input to custom functionality.

What are Scripts?

A script is a Python method that:
  • Has a name starting with script_
  • Takes a gesture parameter
  • Is bound to one or more input gestures
  • Can be assigned to a category for organization
Basic script structure

What are Gestures?

A gesture is user input that can trigger a script:
  • Keyboard: kb:NVDA+t, kb:control+shift+a
  • Braille display: br(freedomScientific):leftWizWheelUp
  • Touch screen: ts:2finger_flickRight
  • Braille keyboard: bk:space+dot1+dot3
Gesture identifiers have the format:

The Script Decorator

The modern way to define scripts uses the @script decorator from scriptHandler:
Script decorator syntax

Decorator Parameters

string
required
Translatable description shown to users in the input gestures dialog
string
Category for grouping related scripts. Use constants from inputCore like:
  • SCRCAT_BROWSE - Browse mode
  • SCRCAT_MISC - Miscellaneous
  • SCRCAT_SPEECH - Speech
  • SCRCAT_SYSTEM - System
  • SCRCAT_CONFIG - Configuration
string
Single gesture identifier to bind
list
List of gesture identifiers to bind
boolean
default:"false"
Whether script applies to focus ancestor objects
boolean
default:"false"
Whether script runs when input help is active
boolean
default:"false"
Whether script runs in sleep mode
int
Say all mode to resume after script executes (from sayAll.CURSOR_* constants)
boolean
default:"false"
Whether script produces speech in “on-demand” mode

Gesture Binding Methods

Using decorator

Method 2: __gestures Dictionary

Using __gestures dictionary
With __gestures, the docstring is used as the description. However, this makes it non-translatable unless you manually set the __doc__ attribute. The decorator approach is preferred.

Method 3: Dynamic Binding

Dynamic binding

Script Resolution Order

When a user presses a key, NVDA searches for a matching script in this order:
1

User Gesture Map

User’s custom key bindings from the input gestures dialog
2

Locale Gesture Map

Locale-specific gesture remappings
3

Braille Display Gestures

Gestures from the active braille display driver
4

Global Plugins

Scripts defined in loaded global plugins
5

App Module

Scripts in the app module for the active application
6

Tree Interceptor

Scripts in the tree interceptor (e.g., browse mode)
7

NVDA Object with Focus

Scripts on the focused NVDA Object
8

Focus Ancestors

Scripts on parent objects (if canPropagate=True)
9

Global Commands

Built-in NVDA commands
The first matching script is executed and the search stops. This allows plugins to override built-in commands by defining them earlier in the chain.

Real-World Examples

Example 1: Simple Global Command

From the NVDA Developer Guide:
Version announcement

Example 2: Window Information Scripts

From the NVDA Developer Guide:
Window utility scripts

Example 3: Object-Specific Script

From the NVDA Developer Guide:
Enhanced edit field
This script only works when an edit field is focused because it’s defined on the EnhancedEditField class.

Example 4: Script with Multiple Gestures

Multiple gestures

Example 5: Script with Repeat Detection

Repeat detection

Gesture Identifier Format

Keyboard Gestures

Keyboard gesture examples

Braille Display Gestures

Braille display gestures

Touch Screen Gestures

Touch gestures

Script Categories

Organize scripts into categories for the input gestures dialog:
Script categories

Advanced Features

Propagating Scripts

Allow scripts to work on focus ancestors:
Propagating script

Bypassing Input Help

Bypass input help

Sleep Mode Scripts

Sleep mode script

Gesture Pass-Through

Pass gesture to the application:
Pass-through

Working with Gesture Objects

The gesture parameter provides information about the input:
Gesture object

Unbinding Gestures

Remove gesture bindings:
Unbinding gestures

Best Practices

Script names should be clear and descriptive:
Write clear, translatable descriptions:
Avoid conflicts with system or NVDA shortcuts:
Assign appropriate categories:
Scripts should not crash:

Testing Scripts

Testing scripts

See Also

NVDA Objects

Define scripts on NVDA Objects

Events

React to system events

Writing Plugins

Create plugins with scripts

Architecture Overview

Understand the system design