pub unsafe fn send_key(
window: *mut c_void,
key_code: u16,
characters: &str,
flags: u64,
)Expand description
Send a key down and up straight to window.
post_key puts the event on the application’s queue, which is what a
tracking menu reads. This hands it to one window with sendEvent:, the same
route send_mouse takes — which is what a check driving a focused view
wants, since it does not depend on which window the application thinks is
key beyond that window being able to accept it at all.
flags are NSEvent.ModifierFlags, so 1 << 20 is Command and 1 << 17
Shift. They are what SwiftUI turns into the EventModifiers a KeyPress
carries.
§Safety
window must be a live NSWindow, and this must run on the main thread.