very basic code editing!

This commit is contained in:
dylan
2023-05-05 11:52:08 -07:00
parent 6b90d883e9
commit 1e91232bd6
9 changed files with 233 additions and 22 deletions

View File

@@ -1,3 +1,5 @@
import { font } from "./font.ts";
const keyboard = new Map<number, {first: boolean, repeat: boolean, held: boolean}>();
export const K = {
@@ -125,4 +127,22 @@ export const getKeysPressed = () => {
return value.first || value.repeat;
}).map(([key]) => key);
return result;
}
export const getKeyboardString = () => {
let str = "";
for (const key of getKeysPressed()) {
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) {
str += char;
}
}
return str;
}