Ok I realized I can be notified in javascript because it is using the Pointer Lock API. So I can do that :
document.addEventListener("pointerlockchange", lockChangeAlert, false); function lockChangeAlert() { console.log("lock change alert"); }
Now I need to notify my game from the javascript.