Skip to content

Commit

Permalink
Adding support for Option key
Browse files Browse the repository at this point in the history
- Since Command is being distinguished in MacOS, we added a
  distinction for the Option key as well.
  • Loading branch information
ostrosco committed Nov 15, 2023
1 parent df04977 commit e5f4f2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/device_state/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use mouse_state::MouseState;

#[derive(Debug, Clone)]
pub struct DeviceState;

const MAPPING: &[(readkey::Keycode, Keycode)] = &[
(readkey::Keycode::_0, Keycode::Key0),
(readkey::Keycode::_1, Keycode::Key1),
Expand Down Expand Up @@ -75,8 +74,8 @@ const MAPPING: &[(readkey::Keycode, Keycode)] = &[
(readkey::Keycode::RightControl, Keycode::RControl),
(readkey::Keycode::Shift, Keycode::LShift),
(readkey::Keycode::RightShift, Keycode::RShift),
(readkey::Keycode::Option, Keycode::LAlt),
(readkey::Keycode::RightOption, Keycode::RAlt),
(readkey::Keycode::Option, Keycode::LOption),
(readkey::Keycode::RightOption, Keycode::ROption),
(readkey::Keycode::Command, Keycode::Command),
(readkey::Keycode::Return, Keycode::Enter),
(readkey::Keycode::Up, Keycode::Up),
Expand Down
4 changes: 4 additions & 0 deletions src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ pub enum Keycode {
LAlt,
RAlt,
Command,
LOption,
ROption,
LMeta,
RMeta,
Enter,
Expand Down Expand Up @@ -174,6 +176,8 @@ impl FromStr for Keycode {
"LAlt" => Ok(Self::LAlt),
"RAlt" => Ok(Self::RAlt),
"Command" => Ok(Self::Command),
"LOption" => Ok(Self::LOption),
"ROption" => Ok(Self::ROption),
"LMeta" => Ok(Self::LMeta),
"RMeta" => Ok(Self::RMeta),
"Enter" => Ok(Self::Enter),
Expand Down

0 comments on commit e5f4f2c

Please sign in to comment.