Possible to access Accelerometer?

I know it is possible to do so with C++, but is it possible to access the accelerometer (for android devices) directly with javascript? Thanks!

Hi, I hope it will help.

MainScene.prototype.onDidLoadFromCCB = function()
{
   this.rootNode.setAccelerometerEnabled(true);
   this.rootNode.onAccelerometer = function(event) {
       this.controller.onAccelerometer(event);
   };
}

MainScene.prototype.onAccelerometer = function(accelEvent) {
}

Hi, I’m new to this.

Where and How do it add this Code ? Do i have to open a new JS file named “Accelerometer.js” (for instance)? How do it link it with my Actor in the code?
Does this work on Android & iOS alike?

Thanks !