Skip to content
Open navbar menu
Sign UpLog In
Profile icon

αɱõԍԋ the cool

"vscode, the best ide is" - Yoda. I'm mainly on replit for the interesting posts. I'm building a choose-your-own-adventure scripting lang.
  • Cube-Fighter

    Cover page
    Made with HTML, CSS, JS

    It has a guy you can control with Arrow Keys (no WASD or LIJK yet), and click to shoot.

    Recent comments (1)
    2 years ago

    For the colours you are basically working with CSS, you can literally use "red" instead of "#AB2328" if it helps. To make your input smoother you could use:

    let Input = {};
    document.addEventListener("keydown", function (e) {
    e = e || window.event;
    Input[e.keyCode] = true;
    Input[e.key.toString().toUpperCase()] = true;
    document.addEventListener("keyup", function (e) {
    e = e || window.event;
    Input[e.keyCode] = false;
    Input[e.key.toString().toUpperCase()] = false;

    Then whenever you want to check if a key is pressed you can do:

    Input.KEY: e.g. Input.W - 'W' key
    Input[keyCode]: e.g. Input[38] - 'Up arrow' key
    For example:
    if (Input.W || Input[38]) {
    console.log("W or Up Arrow is pressed!");

    Hope this helps :)

  • zomb-apocolypse-runnableonrepl

    Cover page
    Made with HTML, CSS, JS
    Recent comments (0)
All Repls