-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What about "Shift", "Alt" and "Ctrl" #43
Comments
Hi @BlockyDeer, yes they're missing. Those keys do not generate any event in the terminal. For some keys, you can try to infer them, i.e., you obtained 'A' instead of 'a', but that could also be due because Caps lock is enabled. |
Can I use the event of Crossterm to get events for those keys? |
I think I am not sure if there exists an easy solution for this... |
idk about ruscii, but in my engine I use smth like this to handle Ctrl+C: use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers};
fn events() {
if is_event_available().unwrap() {
Event::Key(KeyEvent {
code: KeyCode::Char('c'),
modifiers: KeyModifiers::CONTROL,
state: KeyEventState::NONE,
kind: KeyEventKind::Press,
}) => stop_program(),
}
} |
hey, just popping in from another issue in this repo also related to input handling. as i mentioned over there, i was recently using ruscii in my first released app, and was having similar issues. i've since rewritten my app to use crossterm directly instead of relying on ruscii, since my little CLI toy is pretty dead simple to begin with and didn't really need the extra ruscii bits anyway. in any case, just wanted to double up on the suggestion from @TheYahton above, as i just implemented this in my upcoming update and it works like a charm. i'm using 'Q', and <Ctrl+C> all as possible inputs to exit the program, and they all work flawlessly. |
I can't find anything about how to get the state of "Shift", "Alt" and "Ctrl" in this crate. Are they missing?
The text was updated successfully, but these errors were encountered: