pub struct KeyPress {
pub characters: String,
pub modifiers: u64,
pub phase: u64,
}Expand description
Which key was pressed, and with what held down.
The handler used to be told only that a key had been pressed — the
KeyPress arrived by address and was ignored — so a key handler could not
branch on the key, which is the only thing a key handler does.
+0 phase KeyPress.Phases (an option set)
+8 key KeyEquivalent
+24 characters String
+40 modifiers EventModifiers (rawValue: Int)Fields§
§characters: StringWhat was typed — "a", "\u{1b}" for escape, and so on. This is
KeyPress.characters, taken from the stored String.
modifiers: u64The held modifiers, as raw EventModifiers bits. Test them with
KeyPress::holding rather than against numbers of your own.
phase: u64Which phase of the press this is, as raw KeyPress.Phases bits — down,
repeat, up.
Implementations§
Source§impl KeyPress
impl KeyPress
Sourcepub fn holding(&self, modifier: EventModifier) -> bool
pub fn holding(&self, modifier: EventModifier) -> bool
Whether modifier was held.
The bit is read from SwiftUI’s own static rather than written out here:
EventModifiers.shift is a value with a rawValue, and asking for it
is both shorter than a table and correct if the table would have been
wrong.