Window: devicemotion イベント

devicemotion イベントは、一定の間隔で発行され、その時点で端末が受けている加速度の物理的な力の量を示します。また、利用可能であれば、回転率に関する情報も提供します。

バブリング いいえ
キャンセル 不可
インターフェイス DeviceMotionEvent
イベントハンドラープロパティ Window.ondevicemotion

js

function handleMotionEvent(event) {
  var x = event.accelerationIncludingGravity.x;
  var y = event.accelerationIncludingGravity.y;
  var z = event.accelerationIncludingGravity.z;

  // Do something awesome.
}

window.addEventListener("devicemotion", handleMotionEvent, true);

仕様書

Specification
DeviceOrientation Event Specification
# devicemotion
DeviceOrientation Event Specification
# ref-for-dom-window-ondevicemotion

ブラウザーの互換性

BCD tables only load in the browser

関連情報