Skip to content

Commit

Permalink
Ignore key if any of alt/ctrl/meta are pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
walfie committed Jun 16, 2024
1 parent 089ab9e commit 0910b21
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Keyboard.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ let key_of_string = function
| _ -> None
;;

(* TODO: Ignore key when ctrl or cmd are pressed *)
let decode_event =
let open Tea.Json in
Decoder.field "key" Decoder.string |> Decoder.map key_of_string
(* Ignore key if any of alt/ctrl/meta are pressed *)
let ignore_modifier_keys key alt ctrl meta =
if alt || ctrl || meta then None else key_of_string key
in
Decoder.map4
ignore_modifier_keys
(Decoder.field "key" Decoder.string)
(Decoder.field "altKey" Decoder.bool)
(Decoder.field "ctrlKey" Decoder.bool)
(Decoder.field "metaKey" Decoder.bool)
;;

let pressed =
Expand Down

0 comments on commit 0910b21

Please sign in to comment.