Skip to content
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

Get raw bytes of Key #14

Open
kumavale opened this issue Sep 12, 2023 Discussed in #12 · 2 comments
Open

Get raw bytes of Key #14

kumavale opened this issue Sep 12, 2023 Discussed in #12 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@kumavale
Copy link
Owner

Discussed in #12

Originally posted by kumavale September 5, 2023

getch-rs/src/lib.rs

Lines 32 to 75 in 1f1e7fb

pub enum Key {
/// Null byte.
Null,
/// Backspace.
Backspace,
/// Delete key.
Delete,
/// Esc key.
Esc,
/// Up arrow.
Up,
/// Down arrow.
Down,
/// Right arrow.
Right,
/// Left arrow.
Left,
/// End key.
End,
/// Home key.
Home,
/// Backward Tab key.
BackTab,
/// Insert key.
Insert,
/// Page Up key.
PageUp,
/// Page Down key.
PageDown,
/// Function keys.
///
/// Only function keys 1 through 12 are supported.
F(u8),
/// Normal character.
Char(char),
/// Alt modified character.
Alt(char),
/// Ctrl modified character.
///
/// Note that certain keys may not be modifiable with `ctrl`, due to limitations of terminals.
Ctrl(char),
/// Other key.
Other(Vec<u8>),
}

@kumavale kumavale added the enhancement New feature or request label Sep 12, 2023
@kumavale kumavale self-assigned this Sep 12, 2023
@kumavale
Copy link
Owner Author

💡There is no problem in converting Key::Ctrl('z') to &[ ('z' as u8) - b'a' + 1 ] .

@kumavale
Copy link
Owner Author

Since the sizes are different, it should be to_bytes() -> Vec<u8>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant