 				key = type.substring 8
 				keyCode = @keyToKeyCode key
 				keydownListeners[keyCode] = events[type]
+			else if type.indexOf('keyup.') == 0
+				key = type.substring 6
+				keyCode = @keyToKeyCode key
+				keyupListeners[keyCode] = events[type]
 
 	# Map from keyIdentifiers/keyValues to keyCode
 	keyToKeyCodeMap:
-		Backspace: 8
-		Tab: 9
-		Enter: 13
-		Shift: 16
-		Control: 17
-		Alt: 18
-		CapsLock: 20
-		Escape: 27
-		' ': 32  # Space
-		PageUp: 33
-		PageDown: 34
-		End: 35
-		Home: 36
-		ArrowLeft: 37
-		ArrowUp: 38
-		ArrowRight: 39
-		ArrowDown: 40
-		Delete: 46
+		Backspace:    8
+		Tab:          9
+		Enter:       13
+		Shift:       16
+		Control:     17
+		Alt:         18
+		CapsLock:    20
+		Escape:      27
+		' ':         32  # Space
+		PageUp:      33
+		PageDown:    34
+		End:         35
+		Home:        36
+		ArrowLeft:   37
+		ArrowUp:     38
+		ArrowRight:  39
+		ArrowDown:   40
+		Delete:      46
 
 		1: 49
 		2: 50

	# Recieve and bind the mouse/keyboard events listeners
	handleAppEvents: (app, events) ->
		keydownListeners = {}
		window.addEventListener 'keydown', (e) =>
			keydownListeners[e.keyCode]?.call app, e

		for type of events
			if type in ['mousedown', 'mousemove', 'mouseup', 'keydown', 'keyup']

		window.addEventListener 'keyup', (e) =>
			@keyStates[e.keyCode] = no

	# To detect whether a key is pressed down
	isKeyDown: (key) ->
		keyCode = @keyToKeyCode key
		@keyStates[keyCode]
