Skip to content

Commit

Permalink
fix!: map unicode yen to KEY_YEN
Browse files Browse the repository at this point in the history
  • Loading branch information
jtroo committed Aug 8, 2023
1 parent b12b6eb commit 5d9e81d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 5 additions & 4 deletions docs/config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ amount of whitespace (spaces, tabs, newlines) are not relevant. You may use
spaces, tabs, or newlines however you like to visually format `defsrc` to your
liking.

The the primary source of all key names is the
https://github.com/jtroo/kanata/blob/main/parser/src/keys/mod.rs[str_to_oscode]
function in the source code. Please feel free to file an issue if you're unable
to find the key you're looking for.
The the primary source of all key names are the
`str_to_oscode` and `default_mappings` functions in
https://github.com/jtroo/kanata/blob/main/parser/src/keys/mod.rs[the source].
Please feel welcome to file an issue
if you're unable to find the key you're looking for.

An example `defsrc` containing the US QWERTY keyboard keys as an
approximately 60% keyboard layout:
Expand Down
6 changes: 5 additions & 1 deletion parser/src/keys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ fn add_default_str_osc_mappings(mapping: &mut HashMap<String, OsCode>) {
(",", OsCode::KEY_COMMA),
(".", OsCode::KEY_DOT),
("\\", OsCode::KEY_BACKSLASH),
// Mapped as backslash because in some locales/fonts, yen=backslash
("yen", OsCode::KEY_BACKSLASH),
// Unicode yen is probably the yen key, so map this to a separate oscode by default.
("¥", OsCode::KEY_YEN),
];
for dm in default_mappings {
mapping.entry(dm.0.into()).or_insert(dm.1);
Expand Down Expand Up @@ -109,7 +113,7 @@ pub fn str_to_oscode(s: &str) -> Option<OsCode> {
"p" => OsCode::KEY_P,
"lbrc" => OsCode::KEY_LEFTBRACE,
"rbrc" => OsCode::KEY_RIGHTBRACE,
"bksl" | "yen" | "¥" => OsCode::KEY_BACKSLASH,
"bksl" => OsCode::KEY_BACKSLASH,
"caps" => OsCode::KEY_CAPSLOCK,
"a" => OsCode::KEY_A,
"s" => OsCode::KEY_S,
Expand Down

0 comments on commit 5d9e81d

Please sign in to comment.