♻️ Moved namespace for keyboard utils

This commit is contained in:
alonso.torres 2021-02-15 12:15:16 +01:00 committed by Andrés Moya
parent cd313dc2fe
commit baaeb20d6b
35 changed files with 147 additions and 78 deletions

View file

@ -0,0 +1,37 @@
;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
;; This Source Code Form is "Incompatible With Secondary Licenses", as
;; defined by the Mozilla Public License, v. 2.0.
;;
;; Copyright (c) 2020-2021 UXBOX Labs SL
(ns app.util.keyboard)
(defn is-keycode?
[keycode]
(fn [e]
(= (.-keyCode e) keycode)))
(defn ^boolean alt?
[event]
(.-altKey event))
(defn ^boolean ctrl?
[event]
(.-ctrlKey event))
(defn ^boolean meta?
[event]
(.-metaKey event))
(defn ^boolean shift?
[event]
(.-shiftKey event))
(def esc? (is-keycode? 27))
(def enter? (is-keycode? 13))
(def space? (is-keycode? 32))
(def up-arrow? (is-keycode? 38))
(def down-arrow? (is-keycode? 40))