Keyboard In DAT

From TouchDesigner 099 Wiki

Summary

The Keyboard In DAT lists the most recent key events in its FIFO (first in/first out) table. There is one row for every key press down and every key-up, including Shift, Ctrl and Alt, with distinction between left and right side. For convenience, with each key press, a column indicates if the Shift, Ctrl and Alt were being held down at the time.

You get key presses even of the cursor is outside the TouchDesigner windows, whether they are control panels, Perform Mode or the network editor window. Exceptions: while entering text in the editor window.

You can set a filter to watch only certain keys. Custom shortcuts can be defined and handled by a python callback in the attached script.


PythonIcon.png keyboardinDAT_Class

Parameters - Keyboard In Page

Active active - Inhibits and allows message to be added to log.

Perform Window Only perform - When on, key events are only detected while in perform mode.

Keys keys - List of keys to allow through the filter. Just put the characters in the list, space-separated. Eg. '1 2 g h' for the 1, 2, g and h keys. Only these keys will be added to the log and generate an event. If blank, no filtering will be done. List of accepted keys: Keyboard UI

Shortcuts shortcuts - List of shortcuts to watch for. See "Shortcuts" in the notes for defining shortcuts.

Panels panels - Optional list of references to panels to detect events from. Events will only be fired when any of the listed panels has focus.

Left/Right Modifiers lrmodifiers - When on, the states of the left and right modifier keys (see Notes) will be added to the table. Switching the state of this parameter will reset the table's contents.

Parameters - Log Page

Script DAT script - the Script DAT will execute once for each message coming in. See keyboardinDAT_Class for usage.

Execute From executeloc - Determines the location the script is run from.

  • Current Node current - The script is executed from the current node location (for example, where 'cc' points to).
  • Script DAT script - The script is executed from the location of the DAT specified in the Script DAT parameter.
  • Specified Operator op - The script is executed from the operator specified in the From Operator parameter below.

From Operator fromop - The operator whose state change will trigger the DAT to execute its script when Execute is set to Specified Operator. This operator is also the path that the script will be executed from if the Execute From parameter is set to Specified Operator.

Clamp Output clamp - The DAT is limited to 100 messages by default but with Clamp Output, this can be set to anything including unlimited.

Maximum Lines maxlines - Limits the number of messages, older messages are removed from the list first.

Clear Output clear - Deletes all lines except the heading. To clear with a python script op("opname").par.clear.pulse()

Keep First Row firstrow - Keeps first row in table.

Table Output

Below is a list of terms that may be displayed in the Keyboard In DAT's table when certain keys are pressed.

key - Name of the physical key that was pressed or released. This is the value that should be used for shortcuts and key filters.

character - ASCII value of the key pressed, if available. This is the value that would appear from typing the key. Only set on key down events.

alt - State of the alt modifier key.

lalt - State of the left alt modifier key.

ralt - State of the right alt modifier key.

ctrl - State of the ctrl modifier key.

lctrl - State of the left ctrl modifier key.

rctrl - State of the right ctrl modifier key.

shift - State of the shift modifier key.

lshift - State of the left shift modifier key.

rshift - State of the right shift modifier key.

state - State of key associated with this event.

time - Time that the even occurred in milliseconds since the program started.

NOTE The "state" of a key is 1 when the key is down and 0 when it is up.

Notes

Shortcuts - Shortcuts are defined by a list of modifier keys (see below) and a "trigger" key separated by .'s.

For example, ctrl.shift.a the modifier keys are ctrl and shift, and the trigger key is a. This shortcut will be activated when one of the ctrl and shift keys are pressed and the trigger key, a is pressed down. If any other modifier keys are pressed, the shortcut will not be detected.

Modifier Keys - The following are all the valid modifier keys:

  • lalt - Left alt key.
  • ralt - Right alt key.
  • alt - Either left or right alt key.
  • lctrl - Left ctrl key.
  • rctrl - Right ctrl key.
  • ctrl - Either left or right ctrl key.
  • lshift - Left shift key.
  • rshift - Right shift key.
  • shift - Either left or right shift key.