Instance Property

characters

The characters associated with a key-up or key-down event.

Declaration

var characters: String? { get }

Discussion

These characters are derived from a keyboard mapping that associates various key combinations with Unicode characters. This property is only valid for key-up and key-down events. It raises an NSInternalInconsistencyException if accessed on any other kind of event object.

This property is set to an empty string for dead keys, such as Option-e. However, for a key combination such as Option-Shift-e this property is set to the standard accent ("´").

For a list of constants corresponding to commonly-used Unicode characters, see NSText.

See Also

Getting Key Event Information

class var modifierFlags: NSEvent.ModifierFlags

Returns the currently pressed modifier flags.

struct NSEvent.ModifierFlags

Flags that represent key states in an event object.

class var keyRepeatDelay: TimeInterval

Returns the length of time a key must be held down in order to generate the first key repeat event.

class var keyRepeatInterval: TimeInterval

Returns the length between subsequent key repeat events being posted.

var charactersIgnoringModifiers: String?

The characters generated by a key event as if no modifier key (except for Shift) applies.

var isARepeat: Bool

A Boolean value that indicates whether the key event is a repeat.

var keyCode: UInt16

The virtual key code for the keyboard key associated with a key event.