Add Ctrl/Shift + Arrow support (#147)
This commit is contained in:
parent
4fca41d6c5
commit
943d73458f
@ -362,7 +362,17 @@ where
|
||||
_ => InputEvent::Unknown,
|
||||
}
|
||||
}
|
||||
e => match (buf.last().unwrap(), e) {
|
||||
(53, 65) => InputEvent::Keyboard(KeyEvent::CtrlUp),
|
||||
(53, 66) => InputEvent::Keyboard(KeyEvent::CtrlDown),
|
||||
(53, 67) => InputEvent::Keyboard(KeyEvent::CtrlRight),
|
||||
(53, 68) => InputEvent::Keyboard(KeyEvent::CtrlLeft),
|
||||
(50, 65) => InputEvent::Keyboard(KeyEvent::ShiftUp),
|
||||
(50, 66) => InputEvent::Keyboard(KeyEvent::ShiftDown),
|
||||
(50, 67) => InputEvent::Keyboard(KeyEvent::ShiftRight),
|
||||
(50, 68) => InputEvent::Keyboard(KeyEvent::ShiftLeft),
|
||||
_ => InputEvent::Unknown,
|
||||
},
|
||||
}
|
||||
}
|
||||
_ => InputEvent::Unknown,
|
||||
|
@ -111,6 +111,14 @@ pub enum KeyEvent {
|
||||
Ctrl(char),
|
||||
Null,
|
||||
Esc,
|
||||
CtrlUp,
|
||||
CtrlDown,
|
||||
CtrlRight,
|
||||
CtrlLeft,
|
||||
ShiftUp,
|
||||
ShiftDown,
|
||||
ShiftRight,
|
||||
ShiftLeft,
|
||||
}
|
||||
|
||||
/// This type allows you to read the input asynchronously which means that input events are gathered on the background and will be queued for you to read.
|
||||
|
@ -224,6 +224,15 @@ fn handle_key_event(key_event: &KeyEventRecord, seq: &mut Vec<u8>) {
|
||||
VK_LEFT | VK_UP | VK_RIGHT | VK_DOWN => {
|
||||
seq.push(b'\x1B');
|
||||
seq.push(b'[');
|
||||
|
||||
// Modifier Keys (Ctrl, Shift) Support
|
||||
let key_state = &key_event.control_key_state;
|
||||
if key_state.has_state(RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED) {
|
||||
seq.push(53);
|
||||
} else if key_state.has_state(SHIFT_PRESSED) {
|
||||
seq.push(50);
|
||||
}
|
||||
|
||||
seq.push([b'D', b'A', b'C', b'B'][(key_event.virtual_key_code - 0x25) as usize]);
|
||||
}
|
||||
VK_PRIOR | VK_NEXT => {
|
||||
|
Loading…
Reference in New Issue
Block a user