Robert Eisele
Engineer, Systems Architect and DBA

Using Gamepads in JavaScript via node.js

I needed game controller support in node.js for a bigger JavaScript robotics project I'm currently working on. There are a few libraries already but none of them were sufficient for this job, so I wrote an own library called gamecontroller myself.

And talking of game controllers in JavaScript, I'm not talking about some visualization thingy like:

... but rather the communication with a Sony PlayStation controller or a XBOX360 controller. The hard part was already done by Hans Hübner with his HID library for node. The gamecontroller library is thus just a little event handler and button/joystick mapping for several controllers. Working with the library is as easy as this, here for a PlayStation 2 controller:

const GameController = require('gamecontroller');

const gc = new GameController('ps2');


gc.on('X:press', function() {
  console.log("X Pressed");

gc.on('X:release', function() {
  console.log("X Released");

gc.on('JOYL:move', function(o) {

At the moment, only a few controllers are supported, just the ones I could get my hands on. It would be cool if you could provide more configs for your own controllers to make this lib the most complete.

You might also be interested in the following


Sorry, comments are closed for this article. Contact me if you want to leave a note.