--- title: 'Document: pointerlockchange event' slug: Web/API/Document/pointerlockchange_event translation_of: Web/API/Document/pointerlockchange_event ---
{{APIRef}}

pointerlockchange 事件当指针解锁或者被锁定时触发

冒泡 Yes
可取消 No
接口 {{domxref("Event")}}
Event handler property {{domxref("Document/onpointerlockchange", "onpointerlockchange")}}

例子

使用 addEventListener():

document.addEventListener('pointerlockchange', (event) => {
  console.log('Pointer lock changed');
});

使用 onpointerlockchange 事件处理程序属性

document.onpointerlockchange = (event) => {
  console.log('Pointer lock changed');
};

Specifications

Specification Status
{{SpecName('Pointer Lock', '#pointerlockchange-and-pointerlockerror-events')}} {{Spec2('Pointer Lock')}}

浏览器兼容性

{{Compat("api.Document.pointerlockchange_event")}}

参考