PointerLockControl Event


i’m trying to understand how PointerLockControl Events are working .

i ve seen in the code there is 3 event created
var changeEvent = { type: ‘change’ };
var lockEvent = { type: ‘lock’ };
var unlockEvent = { type: ‘unlock’ };

question 1) :i ve seen those event are use cause there is scope.dispatchEvent(change/lock/unlockEvent) in code , but i haven’t seen addEventListerner for this Event and i dont know what is the callback for each event in the scope( scope= three.pointerLockControl object ) .i mean i dont understand what happen when those event are fired .

question 2 ) i does believe to create an Event we need to write var changeEvent=new Event(‘change’);
so i dont understand the write var changeEvent = { type: ‘change’ };

question 3) to lock in canvas wee need to use an addEventlisterner(‘click’, function(){camcontrol.lock(); })
but to escape we need to press esc key and i didn’t find where is the line
with an addeventlistener which listen the esc keypress to unlock .

thanks for your help

ive commented in PointerLockControl all line about change/lock/unlockEvent and everything work well without those line under firefox/chrome ( linux ) and edge(window ) .

Almost all controls fire custom events. You can add event listeners for those events like so:

controls.addEventListener( 'change', myChangeListener );

ok i understand .

the dispatchEvent is in case somebody need to manage this event and he just have to add your line
controls.addEventListener( ‘change’, myChangeListener );

thank you very much