Created
November 14, 2011 17:57
-
-
Save jvillste/1364608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn combined-key-code [key-code] | |
(case key-code | |
left-shift :shift | |
right-shift :shift | |
left-control :control | |
right-control :control | |
left-alt :alt | |
alt-gr :alt | |
nil)) | |
(defn conj-if-not-nil [collection value] | |
(if value | |
(conj collection value) | |
collection)) | |
(defn update-keys-down [keys-down keyboard-event] | |
(case (:type keyboard-event) | |
:key-pressed (-> keys-down | |
(conj (:key-code keyboard-event)) | |
(conj-if-not-nil (combined-key-code (:key-code keyboard-event)))) | |
:key-released (-> keys-down | |
(disj (:key-code keyboard-event)) | |
(disj (combined-key-code (:key-code keyboard-event)))) | |
keys-down)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment