             event.preventDefault()
             @finishRecording "keyboard", key
         else if @keyboardMapping[key]
-            event.preventDefault()
+            event.preventDefault() if @hasFocus()
             @keyboardMapping[key](keyDown)
 
+    hasFocus: ->
+        document.activeElement is document.body
 
     ###########################################################
     # Mouse events handling

    101: "numpad-5", 102: "numpad-6", 103: "numpad-7", 104: "numpad-8", 105: "numpad-9"
    106: "multiply", 107: "add", 109: "subtract", 110: "decimal-point", 111: "divide"

buttonNumberToName = 
    1: "left"
    2: "right"
    3: "middle"

        event or= window.event
        button = buttonNumberToName[event.button or event.which] or "unknown"
        if @recordNextEvent
            event.preventDefault() if @hasFocus()
            @finishRecording "mouse", button
        else if @isMouseInActiveArea()
            @mouseMapping[button]?(buttonDown)
