The OpenD Programming Language

KeyDownEvent

Indicates that the user has pressed a key on the keyboard, or if they've been holding it long enough to repeat (key down events are sent both on the initial press then repeated by the OS on its own time.) For available properties, see KeyEventBase.

More...
class KeyDownEvent : KeyEventBase {
enum EventString;
}

Inherited Members

From KeyEventBase

key
Key key;
ctrlKey
bool ctrlKey;
altKey
bool altKey;
shiftKey
bool shiftKey;

Indicates the current state of the given keyboard modifier keys.

state
int state;

The raw bitflags that are parsed out into ctrlKey, altKey, and shiftKey.

Detailed Description

You can construct these yourself, but generally the system will send them to you and there's little need to emit your own.

Please note that a KeyDownEvent will also often send a CharEvent, but there is not necessarily a one-to-one relationship between them. For example, a capital letter may send KeyDownEvent for Key.Shift, then KeyDownEvent for the letter's key (this key may not match the letter due to keyboard mappings), then CharEvent for the letter, then KeyUpEvent for the letter, and finally, KeyUpEvent for shift.

For some characters, there are other key down events as well. A compose key can be pressed and released, followed by several letters pressed and released to generate one character. This is why CharEvent is a separate entity.

See Also

Meta

History

Added May 2, 2021. Previously, it was only seen as the base Event class on "keydown" event listeners.