mheavers
mheavers

Reputation: 30158

javascript / threejs - detect when a key is released

I'm using this javascript keyboard library for threejs, and it seems as though it is able to detect when a key is released. How would I incorporate this into my project? Here is the documentation:

http://learningthreejs.com/data/THREEx/docs/THREEx.KeyboardState.html

and here is how I currently detect which key is pressed:

if (keyboard.pressed("left")){ 
//do stuff
}

Upvotes: 2

Views: 3138

Answers (1)

MushinNoShin
MushinNoShin

Reputation: 4886

In the source for threejs, there's a line

document.addEventListener("keyup", this._onKeyUp, false);

You're adding a handler, listening for the keyup event.

The MDC docs for addEventListener: https://developer.mozilla.org/en/DOM/element.addEventListener

Upvotes: 1

Related Questions