The "accelerator" function gets an extension a place in the keyboard processing queue:
(Quoting from reaper_plugin.h)
Code:
/*
** accelerator_register_t allows you to register ("accelerator") a record which lets you get a place in the
** keyboard processing queue.
*/
typedef struct accelerator_register_t
{
// translateAccel returns:
// 0 if not our window,
// 1 to eat the keystroke,
// -1 to pass it on to the window,
// -666 to force it to the main window's accel table (with the exception of ESC)
int (*translateAccel)(MSG *msg, accelerator_register_t *ctx);
bool isLocal; // must be TRUE, now (false is no longer supported, heh)
void *user;
} accelerator_register_t;
This ability to eat keystrokes would be very useful for deferred scripts:
* The script can detect a keystroke and terminate itself, thereby skipping the strange "ReaScript task control" dialog that
confuses new users.
* Alternatively, instead of starting and stopping the script by two separate keystrokes, the script can run while the shortcut key is held down, and terminate when the key is released. Many users find this more natural, and more similar to REAPER's native mouse modifier actions.
* The script can be controlled by keystrokes, without triggering action shortcuts. For example, ESC can terminate the script, instead of closing the MIDI editor.
Unfortunately, the MIDI editor and inline editor appear to jump the queue when they are focused, inserting themselves ahead of the extension's accelerator in the keyboard processing queue. The accelerator can therefore not eat keystrokes that go to the these windows, and deferred scripts cannot take advantage of the above-mentioned applications.