Skip to content

Commit

Permalink
Determine which identifier to use upon compile time (#135)
Browse files Browse the repository at this point in the history
* Determine which identifier to use upon compile time

* Fix

---------

Co-authored-by: Max Bergmark <[email protected]>
  • Loading branch information
friendlymatthew and maxbergmark authored Sep 4, 2024
1 parent daa7845 commit 0f9eeee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions leptos_hotkeys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ web-sys.workspace = true
[features]
debug = ["dep:log"]
ssr = []
use_key = []
10 changes: 7 additions & 3 deletions leptos_hotkeys/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,12 @@ pub fn use_hotkeys_context() -> HotkeysContext {

#[cfg(not(feature = "ssr"))]
fn clean_key(event: &web_sys::KeyboardEvent) -> String {
match event.key().as_str() {
" " => "spacebar".to_string(),
_ => event.key().to_lowercase(),
if cfg!(feature = "use_key") {
match event.key().as_str() {
" " => "spacebar".to_string(),
key => key.to_lowercase(),
}
} else {
event.code().to_lowercase()
}
}

0 comments on commit 0f9eeee

Please sign in to comment.