core: add KeyEvent

This commit is contained in:
Mitchell Hashimoto
2023-08-16 08:12:07 -07:00
parent 01282d3d15
commit 62081a51b0

View File

@ -1139,6 +1139,40 @@ pub fn charCallback(
try self.io_thread.wakeup.notify();
}
/// A key input event.
pub const KeyEvent = struct {
/// The action: press, release, etc.
action: input.Action,
/// "key" is the logical key that was pressed. For example, if
/// a Dvorak keyboard layout is being used on a US keyboard,
/// the "i" physical key will be reported as "c". The physical
/// key is the key that was physically pressed on the keyboard.
key: input.Key,
physical_key: input.Key,
/// Mods are the modifiers that are pressed.
mods: input.Mods,
/// The mods that were consumed in order to generate the text
/// in utf8. This has the mods set that were consumed, so to
/// get the set of mods that are effective you must negate
/// mods with this.
///
/// This field is meaningless if utf8 is empty.
consumed_mods: input.Mods,
/// Composing is true when this key event is part of a dead key
/// composition sequence and we're in the middle of it.
composing: bool,
/// The utf8 sequence that was generated by this key event.
/// This will be an empty string if there is no text generated.
/// If composing is true and this is non-empty, this is preedit
/// text.
utf8: []const u8,
};
/// Called for a single key event.
///
/// This will return true if the key was handled/consumed. In that case,