diff options
Diffstat (limited to 'public/gl/io')
| -rw-r--r-- | public/gl/io/File.js (renamed from public/gl/io/file.js) | 4 | ||||
| -rw-r--r-- | public/gl/io/Input.js | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/public/gl/io/file.js b/public/gl/io/File.js index f89565c..2b3c23b 100644 --- a/public/gl/io/file.js +++ b/public/gl/io/File.js @@ -1,6 +1,6 @@ -export { readFileAsync } +export const File = {} -const readFileAsync = async (path) => { +File.readFileAsync = async (path) => { try { let data = await fetch(path) let text = await data.text() diff --git a/public/gl/io/Input.js b/public/gl/io/Input.js new file mode 100644 index 0000000..ecc4af5 --- /dev/null +++ b/public/gl/io/Input.js @@ -0,0 +1,16 @@ +export const Input = {} + +const keys = {} +Input.setup = () => { + document.onkeydown = function(e) { + keys[e.key] = true + + }; + document.onkeyup = function(e) { + keys[e.key] = false + } +} + +Input.isKeyDown = (key) => { + return keys[key] +}
\ No newline at end of file |