Odyc.js

🎮 Custom Controls

By default, Odyc.js uses the arrow keys and Space or Enter to move and interact.

But you can fully redefine the control scheme using the controls option.


🧩 Default Setup

Here’s the default control configuration if none is specified:

controls: {
  LEFT: 'ArrowLeft',
  RIGHT: 'ArrowRight',
  UP: 'ArrowUp',
  DOWN: 'ArrowDown',
  ACTION: ['Enter', 'Space']
}

⚙️ Customizing the Keys

You can override this configuration when calling createGame():

createGame({
	controls: {
		LEFT: 'KeyA',
		RIGHT: 'KeyD',
		UP: 'KeyW',
		DOWN: 'KeyS',
		ACTION: 'ShiftLeft'
	}
})

Each key can be:

  • a string representing a keyboard key ('z', 'ArrowLeft', 'Shift', etc.)
  • or an array of strings if you want to allow multiple keys for the same action

🔑 Recognized Keys

Key names follow the standard KeyboardEvent.code values in JavaScript.

The KeyboardEvent.code represents the physical key on the keyboard, not the character it generates.

For example, the code is "KeyQ" for the physical Q key, which produces different characters depending on the keyboard layout.

Press a key to see its code:


🎯 Available Actions

Here are the keys you can customize:

KeyAction performed
UPMove the player up
DOWNMove the player down
LEFTMove the player left
RIGHTMove the player right
ACTIONSkip dialog or message