performKeyPress

suspend fun <T : Component> SwingNodeInteraction<T>.performKeyPress(keyCode: Int, modifiers: Int = 0): SwingNodeInteraction<T>

Presses and releases the key keyCode on the matched node, holding modifiers for both, then settles the composition. keyCode is a KeyEvent.VK_* constant and modifiers a mask of InputEvent.*_DOWN_MASK values, empty by default.

The press and the release arrive an event-queue cycle apart, and travel the node's own key handling: its key listeners run and its input and action maps are consulted, so a key stroke a widget binds to an action performs that action. This is the gesture for a key that means something other than a character - Enter, Escape, an arrow, a shortcut. It delivers no KEY_TYPED, which is the event that inserts a character; type text with performTyping.

The events are delivered to the node as though it owned the focus; see deliverKeyPressed for what that does and does not mean off a realized window.

Return

this interaction, for chaining a further gesture or assertion.

Parameters

keyCode

the code both events carry, which is what an input map matches a key stroke on.

modifiers

the mask held across both events; the modifier keys themselves are not delivered, only reported as held.