Skip to content

Commit

Permalink
Add '\r' back for the KeyEvent::Enter (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
zrzka authored and TimonPost committed Sep 20, 2019
1 parent 4952cb3 commit 60cd127
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions crossterm_input/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub enum KeyEvent {
End,
PageUp,
PageDown,
Tab,
BackTab,
Delete,
Insert,
Expand Down
4 changes: 2 additions & 2 deletions crossterm_input/src/input/unix_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ where
None => InputEvent::Keyboard(KeyEvent::Esc),
}
}
b'\n' => InputEvent::Keyboard(KeyEvent::Enter),
b'\t' => InputEvent::Keyboard(KeyEvent::Char('\t')),
b'\r' | b'\n' => InputEvent::Keyboard(KeyEvent::Enter),
b'\t' => InputEvent::Keyboard(KeyEvent::Tab),
b'\x7F' => InputEvent::Keyboard(KeyEvent::Backspace),
c @ b'\x01'..=b'\x1A' => {
InputEvent::Keyboard(KeyEvent::Ctrl((c as u8 - 0x1 + b'a') as char))
Expand Down
2 changes: 1 addition & 1 deletion crossterm_input/src/input/windows_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ fn parse_key_event_record(key_event: &KeyEventRecord) -> Option<KeyEvent> {
if character == '\t' {
Some(KeyEvent::BackTab)
} else {
Some(KeyEvent::Char(character))
Some(KeyEvent::Tab)
}
} else {
Some(KeyEvent::Char(character))
Expand Down

0 comments on commit 60cd127

Please sign in to comment.