User Reference:KeystrokeFilter
Function
The KeystrokeFilter translates BCI2000 state changes into simulated keypresses. Simulated keypresses can then be used to control an external application program installed on the machine running the BCI2000 application module. Only the lower 4 bit of the state value are used, and translated into presses of the keys corresponding to their hexadecimal representation (0..9, A..F).
Alternatively, a mathematical expression may be specified which evaluates to a virtual key code.
Parameters
KeystrokeStateName
The name of a BCI2000 state to be converted into simulated keystrokes. Keypresses are sent only when the state value changes.
KeystrokeExpression
A mathematical expression that evaluates to a virtual key code (for non-control keys, the virtual key code matches the ASCII value of the character printed on the key). For each data block in which this expression evaluates to a number between 1 and 254, one key press is generated. Use expression variables to suppress repeated pressing of the same key (example below).
KeystrokeExpressionOnStartRun
A mathematical expression that is evaluated at the beginning of each run (i.e., when "Start" or "Resume" is clicked). This is useful for the initialization of variables that are to be used inside the keystroke expression.
States
Any existing state may be given in the KeystrokeStateName parameter, or referenced from KeystrokeExpression and KeystrokeExpressionOnStartRun.
Example
This example uses expressions to send keystrokes. When the control signal in y direction is greater 0, a press of the '1' key is generated. Otherwise, a press of the space key is generated. Repeated keystrokes for the same key are suppressed.
KeystrokeExpression= key:=(Signal(2,1)>0)?49:48;result:=(key==prev)?0:key;prev:=key;result KeystrokeExpressionOnStartRun= prev:=0;
See also
User Reference:MouseFilter, User Reference:KeyLogFilter, User Reference:JoystickFilter