4
4
#
5
5
6
6
defmodule Scenic.Driver.KeyMap do
7
- @ moduledoc false
7
+ @ moduledoc """
8
+ Behaviour and support functions for mapping physical keys to characters.
9
+
10
+ This module is meant to be implemented elsewhere and provided to a driver
11
+ in order to localize key presses into the correct characters.
12
+
13
+ The `:scenic_driver_local` driver comes with a USEnglish key map, which it
14
+ uses by default. Look at that one as an example on how to make a custom
15
+ key mapping.
16
+ """
8
17
9
18
# @doc """
10
19
# Map of current key state. A key with a value of 1 is pressed. A key with
@@ -15,7 +24,15 @@ defmodule Scenic.Driver.KeyMap do
15
24
# """
16
25
@ type keys :: % { atom => integer }
17
26
18
- @ type mods :: [ :meta | :alt | :ctrl | :shift | :caps_lock | :num_lock | :scroll_lock ]
27
+ @ type mod_keys :: [
28
+ :meta
29
+ | :alt
30
+ | :ctrl
31
+ | :shift
32
+ | :caps_lock
33
+ | :num_lock
34
+ | :scroll_lock
35
+ ]
19
36
20
37
@ doc """
21
38
Translate a key to a codepoint, which is really just a string.
@@ -25,7 +42,7 @@ defmodule Scenic.Driver.KeyMap do
25
42
26
43
If the mapping is successful, i.e. the key press results in a valid character,
27
44
Then this function should return `{ :ok, codepoint, state }`. The returned
28
- codepoint will be sent on to the ViewPort as a codepoint intput event.
45
+ codepoint will be sent on to the ViewPort as a codepoint input event.
29
46
30
47
If the key press does not map to a string (this is common), then the function
31
48
should return `{ :ok, nil, state }`. This will not result in a codepoint input
@@ -115,7 +132,7 @@ defmodule Scenic.Driver.KeyMap do
115
132
@ doc """
116
133
Generate the list of pressed modifier keys
117
134
"""
118
- @ spec mods ( keys :: keys ) :: mods
135
+ @ spec mods ( keys :: keys ) :: mod_keys
119
136
def mods ( keys ) do
120
137
[ ]
121
138
|> add_if_set ( :meta , meta? ( keys ) )
0 commit comments