1. 開発者向けのウェブ技術
  2. Web API
  3. Document
  4. pointerlockchange

このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

Document: pointerlockchange イベント

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

pointerlockchange イベントは、ポインターがロックされたり解除されたりしたときに発行されます。

イベントハンドラーは Document.pointerLockElement を使用して、ポインターがロックされているかどうか、ロックされている場合はどの要素にロックされているかを判断することができます。

このイベントはキャンセル不可で、バブリングしません。

構文

このイベント名を addEventListener() などのメソッドで使用するか、イベントハンドラーのプロパティを設定するかしてください。

js
addEventListener("pointerlockchange", (event) => {});
onpointerlockchange = (event) => {};

イベント型

一般的な Event です。

addEventListener() を使用した場合

js
addEventListener("pointerlockchange", (event) => {
 if (document.pointerLockElement)
 console.log("The pointer is locked to: ", document.pointerLockElement);
 else {
 console.log("The pointer is not locked");
 }
});

onpointerlockchange イベントハンドラープロパティを使用した場合

js
document.onpointerlockchange = (event) => {
 if (document.pointerLockElement)
 console.log("The pointer is locked to: ", document.pointerLockElement);
 else {
 console.log("The pointer is not locked");
 }
};

仕様書

Specification
Pointer Lock 2.0
# pointerlockchange-and-pointerlockerror-events
Pointer Lock 2.0
# dom-document-onpointerlockchange

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /