Documentation
¶
Overview ¶
Package key represents keys on the keyboard that the user might type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringToKeys ¶
StringToKeys returns a sequence of Key given an input string s containing text. If the string contains upper-case letters, the sequence will include a keydown event for the shift key, the keydown/keyup events for the actual key, and finally the keyup event for the shoft key.
func WithKeydownDelay ¶ added in v0.11.3
func WithKeyupDelay ¶ added in v0.11.3
Types ¶
type Key ¶
type Key struct {
Key string
Letter string
// KeydownDelay defines the simulated delay after the keydown event before
// the next keyevent is dispatched.
KeydownDelay time.Duration
// KeyupDelay defines the simulated delay after the keyup event before the
// next keyevent is dispatched.
KeyupDelay time.Duration
Down, Up bool
}
Key represents a single keyboard input. WARNING: This is experimental.
The fields Up and Down indicate if up/down events should be dispatched, which is used for simple modifier keys, e.g., the sequence Shift+A would generate the following sequence:
- Key: Shift, Down: true, Up: false
- Key: A, Down: true, Up: true
- Key: Shift, Down: false, Up: true
Modifier states are not properly represented, the individual keyboard events do not contain modifier information, i.e., in the previous example, the event for the "A" key doesn't include the shiftKey yet.
When simulating a string of keyboard events, KeydownDelay and KeyupDelay describes simulated delay after the keydown/keyup event before the next keyboard event in the sequence.
func (Key) EventInit ¶ added in v0.9.1
func (k Key) EventInit() uievents.KeyboardEventInit
EventInit creates a KeyboardEventInit representing the key stroke.