"Fix" getStringForKeyCode returning incorrect strings (#753)

* Fix getStringForKeyCode returning wrong result

This adds the full stop/period (.) key to the switch statement, and replaces String.fromCharCode (which works with Unicode) with the replacement character (�).

* Make letter keys work properly

* Add digits and display unknown codes in brackets

* better formatting
This commit is contained in:
EmeraldBlock 2020-10-04 03:34:40 -05:00 committed by GitHub
parent 7517d4a979
commit 0481c84e72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -248,6 +248,8 @@ export function getStringForKeyCode(code) {
return ",";
case 189:
return "-";
case 190:
return ".";
case 191:
return "/";
case 219:
@ -260,7 +262,9 @@ export function getStringForKeyCode(code) {
return "'";
}
return String.fromCharCode(code);
return (48 <= code && code <= 57) || (65 <= code && code <= 90)
? String.fromCharCode(code)
: "[" + code + "]";
}
export class Keybinding {