Skip to content

Commit

Permalink
Fix on detecting backspace on not windows os
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiopelliccione committed Nov 12, 2023
1 parent 1682444 commit 91fa87c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/parse-keypress.ts
Expand Up @@ -138,8 +138,11 @@ type ParsedKey = {
};

const parseKeypress = (s: Buffer | string = ''): ParsedKey => {

let parts;

let isWindows = process.platform === "win32";

if (Buffer.isBuffer(s)) {
if (s[0]! > 127 && s[1] === undefined) {
(s[0] as unknown as number) -= 128;
Expand Down Expand Up @@ -175,7 +178,7 @@ const parseKeypress = (s: Buffer | string = ''): ParsedKey => {
} else if (s === '\t') {
// tab
key.name = 'tab';
} else if (s === '\b' || s === '\x1b\b') {
} else if (!isWindows && s === '\x7f' || s === '\b' || s === '\x1b\b') {
// backspace or ctrl+h
key.name = 'backspace';
key.meta = s.charAt(0) === '\x1b';
Expand Down

0 comments on commit 91fa87c

Please sign in to comment.