OasisWManual 한국어
Section 9. Scripting How-to Pending 3

Keyboard, mouse, and touch input

This page explains how to receive keyboard, mouse and touch input in a script. You get input through this.app.keyboard, this.app.mouse and this.app.touch.

In a test on 2026-10-29, launching a new project on oasisw.ai in desktop Chrome, this.app.keyboard and this.app.mouse were present and this.app.touch was empty (null). Devices without a touch screen have no touch input.

The keyboard and mouse examples were tested the same day: we created scripts with the same code in a launched game, attached them, and actually pressed keys and clicked the screen (1 run each).

Before you start

  • Check that the input devices you need are turned on in SETTINGS → INPUT (Keyboard, Mouse, Touch, Gamepads). Scene settings and editor settings
  • In the launched game tab, click the game view once before key input is received.

Keyboard

While held down: isPressed

var SideMove = ow.createScript('sideMove');
SideMove.attributes.add('speed', { type: 'number', default: 3 });

SideMove.prototype.update = function (dt) {
    var kb = this.app.keyboard;
    var x = 0;
    if (kb.isPressed(ow.KEY_LEFT)) x -= 1;
    if (kb.isPressed(ow.KEY_RIGHT)) x += 1;
    this.entity.translate(x * this.speed * dt, 0, 0);
};

In our test, pressing the right arrow key moved the entity along +X.

Once, at the moment of pressing: wasPressed

Jump.prototype.update = function (dt) {
    if (this.app.keyboard.wasPressed(ow.KEY_SPACE)) {
        this.entity.rigidbody.applyImpulse(0, 5, 0);
    }
};

In our test, holding the space bar for 0.12 seconds made Box (Dynamic Rigid Body) jump once, rising from a height of 0.5 to 1.73. When the same key was pressed and released in less than one frame (pressed by an automation tool), wasPressed didn't catch it. It does catch presses of human length.

Key names start with ow.KEY_. In our test, ow.KEY_LEFT was 37 and ow.KEY_SPACE was 32. Letter keys are ow.KEY_A–ow.KEY_Z, and number keys are ow.KEY_0–ow.KEY_9.

Mouse

Shoot.prototype.initialize = function () {
    this.app.mouse.on(ow.EVENT_MOUSEDOWN, this.onMouseDown, this);
    this.on('destroy', function () {
        this.app.mouse.off(ow.EVENT_MOUSEDOWN, this.onMouseDown, this);
    }, this);
};

Shoot.prototype.onMouseDown = function (event) {
    if (event.button === ow.MOUSEBUTTON_LEFT) {
        console.log('Click: ' + event.x + ', ' + event.y);
    }
};

In our test, clicking the game view called onMouseDown with the clicked coordinates. ow.EVENT_MOUSEDOWN was 'mousedown' and ow.MOUSEBUTTON_LEFT was 0. For on-screen buttons, a button's click event is easier than mouse events. Buttons fire the same event on touch. Pending Test button click on a phone

Touch

On touch devices, you receive ow.EVENT_TOUCHSTART ('touchstart') and other events through this.app.touch. On desktop, this.app.touch is null, so code that uses touch should check that it exists first.

if (this.app.touch) {
    this.app.touch.on(ow.EVENT_TOUCHSTART, this.onTouch, this);
}

Pending Test touch input on a phone

Let the AI do it

State the exact keys in your prompt. In our tests for the contest, the keys written in the prompt were respected every time.

Move Ball left and right with the left and right arrow keys, and make it jump once when the space bar is pressed.
On phones, tapping the left or right half of the screen should move it in that direction.
Don't touch anything else.

Pending Test "Let the AI do it": same prompt 3 times, including on a phone

Next steps

Source scripting/input.html