 				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

		']': 221
		'\\': 220

	# Map from not standard, but commonly known keyValues/keyIdentifiers
	keyAliasToKeyMap:
		Ctrl: 'Control'          #17
		Ctl: 'Control'           #17
		Esc: 'Escape'            #27
		Space: ' '               #32
		PgUp: 'PageUp'           #33
		'Page Up': 'PageUp'      #33
		PgDn: 'PageDown'         #34
		'Page Down': 'PageDown'  #34
		Left: 'ArrowLeft'        #37
		Up: 'ArrowUp'            #38
		Right: 'ArrowRight'      #39
		Down: 'ArrowDown'        #40
		Del: 'Delete'            #46

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

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