Block Group: | Logic |
Icon: |
Listens for a keyboard event and returns a code for the key that caused the event. Fires a trigger when the event is detected.
For information on using dataflow blocks, see Dataflow.
These properties can take input and give output.
input specifies the event that triggers this block. Make sure that you have selected the correct parent element for the event, and then find the event in the Advanced properties and bind it to this property. Valid events are:
active sets or returns whether this block is currently listening for the specified event.
fastResponse determines whether the fastResponse feature is enabled. Use this feature when you troubleshoot performance speed issues relating to this block.
filter specifies the keystroke to listen for. This can be a character, or one of the following strings:
Do not include quotation marks.
output fires when the specified event occurs.
These properties can give output. They cannot take input.
event returns the name of the event type that triggers this block, such as onKeyDown
.
keyCode returns the key code of the last key to undergo key down or key up, whichever was specified. Refer to instances of JavaScript keyCode
.
ctrl for an onKeyUp event, returns whether Ctrl is still being held, if it was held with the last key typed. For anOnKeyDown event, returns whether Ctrl was the last key down.
alt for an onKeyUp event, returns whether Alt is still being held, if it was held with the last key typed. For anOnKeyDown event, returns whether Alt was the last key down.
shift for an onKeyUp event, returns whether Shift is still being held, if it was held with the last key typed. For anOnKeyDown event, returns whether Shift was the last key down.
meta for an onKeyUp event, returns whether Meta is still being held, if it was held with the last key typed. For anOnKeyDown event, returns whether Meta was the last key down.
This is a basic use of the block.
Dataflow Model | Description |
---|---|
When the user types z the background color changes, and when the user types x the color is reverted. |
To force a text input component to revert to its placeholder text when the user types the Esc key:
esc
.@parent.unfocus = Math.random(); @parent.value = @parent.placeholder.value;
Now, when the user starts entering text in the component and presses the Esc key, the text reverts to the placeholder.
This thread in the DGLogik Community Forum shows a use case for the block: