Pointer/Cursor locking and unlocking

Hello,

I’m really not sure if anyone can help on here but here goes.
I’m working on a WebGL app with Unity. I can’t link it as I’m working on it for a company. I have it working so the mouse will lock but once I unlock using ESC or a function WebGL will no longer recorganize mouse clicks.

canvas.requestPointerLock = canvas.requestPointerLock || canvas.mozRequestPointerLock; canvas.addEventListener('mousedown', function(evt) { if(evt.button == 2) { canvas.requestPointerLock(); } });

Thanks to anyone that can help.