Better typing

This commit is contained in:
dylan
2023-05-02 18:44:27 -07:00
parent 253b8e9567
commit 99a8c500c7
2 changed files with 55 additions and 9 deletions

11
repl.ts
View File

@ -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;
}