pub fn register_keybind_with_struct(
identifier: impl AsRef<str>,
handler: RawKeybindHandler,
keybind: Keybind,
) -> Revertible<impl Fn() + Send + Sync + Clone + 'static>Expand description
Registers a new keybind using a Keybind struct.
Returns a Revertible to revert the register.
ยงUsage
use nexus::keybind::{register_keybind_with_struct, Keybind, keybind_handler};
let keybind = Keybind {
key: 123,
alt: true,
ctrl: false,
shift: true,
};
let keybind_handler = keybind_handler!(|id, is_release| {
use nexus::log::{log, LogLevel};
log(LogLevel::Info, "My Addon", format!(
"keybind {id} {}",
if is_release { "released" } else { "pressed "},
));
});
register_keybind_with_struct("MY_KEYBIND", keybind_handler, keybind)
.revert_on_unload();