mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
♻️ Moved namespace for keyboard
utils
This commit is contained in:
parent
cd313dc2fe
commit
baaeb20d6b
35 changed files with 147 additions and 78 deletions
37
frontend/src/app/util/keyboard.cljs
Normal file
37
frontend/src/app/util/keyboard.cljs
Normal 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))
|
Loading…
Add table
Add a link
Reference in a new issue