🐛 Fix problems with CTRL in MacOS

This commit is contained in:
alonso.torres 2022-03-24 14:45:52 +01:00
parent 5a591d2acd
commit 32e4569495
14 changed files with 120 additions and 68 deletions

View file

@ -4,37 +4,45 @@
;;
;; Copyright (c) UXBOX Labs SL
(ns app.util.keyboard)
(ns app.util.keyboard
(:require
[app.config :as cfg]))
(defn is-key?
[key]
(fn [e]
[^string key]
(fn [^js e]
(= (.-key e) key)))
(defn ^boolean alt?
[event]
[^js event]
(.-altKey event))
(defn ^boolean ctrl?
[event]
[^js event]
(.-ctrlKey event))
(defn ^boolean meta?
[event]
[^js event]
(.-metaKey event))
(defn ^boolean shift?
[event]
[^js event]
(.-shiftKey event))
(defn ^boolean mod?
[^js event]
(if (cfg/check-platform? :macos)
(meta? event)
(ctrl? event)))
(def esc? (is-key? "Escape"))
(def enter? (is-key? "Enter"))
(def space? (is-key? " "))
(def up-arrow? (is-key? "ArrowUp"))
(def down-arrow? (is-key? "ArrowDown"))
(def altKey? (is-key? "Alt"))
(def ctrlKey? (or (is-key? "Control")
(is-key? "Meta")))
(def alt-key? (is-key? "Alt"))
(def ctrl-key? (is-key? "Control"))
(def meta-key? (is-key? "Meta"))
(def comma? (is-key? ","))
(def backspace? (is-key? "Backspace"))