Better typing
This commit is contained in:
11
repl.ts
11
repl.ts
@ -1,12 +1,19 @@
|
||||
import faux from "./builtins.ts";
|
||||
import { getKeysPressed } from "./keyboard.ts";
|
||||
import { getKeysPressed, shiftKeyDown, shiftMap } from "./keyboard.ts";
|
||||
import { font } from "./font.ts";
|
||||
|
||||
let line = "";
|
||||
|
||||
const update = () => {
|
||||
for (const key of getKeysPressed()) {
|
||||
const char = key.toLowerCase();
|
||||
let char = String.fromCharCode(key).toLowerCase();
|
||||
if (shiftKeyDown()) {
|
||||
if (char in shiftMap) {
|
||||
char = shiftMap[char as keyof typeof shiftMap];
|
||||
} else {
|
||||
char = char.toUpperCase();
|
||||
}
|
||||
}
|
||||
if (char in font) {
|
||||
line += char;
|
||||
}
|
||||
|
Reference in New Issue
Block a user