         @on_key_up? and window.removeEventListener 'keyup', @_on_key_up
         @on_wheel? and root.removeEventListener 'wheel', @_on_wheel_listener
         # @on_click? and removeListener root, 'click', @on_click
+        document.removeEventListener 'pointerlockchange', @_pointerlockchange, false
+
+    _pointerlockchange: (event) =>
+        root = @_root
+        options = if supports_passive_events then {passive: false} else false
+        if document.pointerLockElement?
+            @locked = true
+            if @_on_pointer_move?
+                removeListener window, 'pointermove', @_on_pointer_move, options
+                removeListener window, 'pointerout', @_on_pointer_move, options
+                addListener root, 'mousemove', @_on_pointer_move, options
+                addListener root, 'mouseout', @_on_pointer_move, options
+            if @on_pointer_down?
+                removeListener root, 'pointerdown', @_on_pointer_down, options
+                addListener root, 'mouserdown', @_on_pointer_down, options
+            if @on_pointer_up?
+                removeListener window, 'pointerup', @_on_pointer_up, options
+                addListener root, 'mouseup', @_on_pointer_up, options
+            @on_lock?()
+        else
+            @locked = false
+            if @_on_pointer_move?
+                removeListener root, 'mousemove', @_on_pointer_move, options
+                removeListener root, 'mouseout', @_on_pointer_move, options
+                addListener window, 'pointermove', @_on_pointer_move, options
+                addListener window, 'pointerout', @_on_pointer_move, options
+            if @on_pointer_down?
+                removeListener root, 'mouserdown', @_on_pointer_down, options
+                addListener root, 'pointerdown', @_on_pointer_down, options
+            if @on_pointer_up?
+                removeListener root, 'mouseup', @_on_pointer_up, options
+                addListener window, 'pointerup', @_on_pointer_up, options
+            @on_unlock?()
 
 options = Object.defineProperty {}, 'passive', get: ->
     supports_passive_events = true

        @_root = @context.root
        @context.behaviours.push @
        @init_time = performance.now()
        @_enabled = false
        @_object_under_pointer = {}
        @_last_hit = {}

        return

    _on_pointer_move: (event) =>
        if @_prevent_defaults
            event.preventDefault()
        # TODO: Use pointerIDs, both for deltas and for viewport/object over/out
        x = event.pageX - @context.root_rect.left
        y = event.pageY - @context.root_rect.top
        prev = @_prev_events['mouse']
        if not prev?
            prev = @_prev_events['mouse'] = {x, y}
        if @locked
            delta_x = event.movementX
            delta_y = event.movementY
        else
            delta_x = x - prev.x
            delta_y = y - prev.y
        prev.x = x; prev.y = y
        {button, buttons, shiftKey, ctrlKey, altKey, metaKey} = event
        # TODO: Should we only lock outside the window?
