GPIO
SimulRPi.mapping
Content of the default keymap dictionary (key: keyboard key as string
, value: GPIO channel as int
):
../SimulRPi/default_keymap.py
Important
There are some platform limitations on using some of the keyboard keys with pynput
.
For instance, on macOS some keyboard keys may require that you run your script with sudo. All alphanumeric keys and some special keys (e.g. backspace
and right
) require sudo. In the content of default_key_to_channel_map <content-default-keymap-label>
shown previously, I commented those keyboard keys that need sudo on macOS. The others don't need sudo on macOS such as cmd_r
and shift
.
For more information about those platform limitations, see pynput documentation.
Warning
If you want to be able to run your python script with sudo in order to use some keys that require it, you might need to edit /etc/sudoers to add your PYTHONPATH
if your script makes use of your PYTHONPATH
as setup in the ~/.bashrc file. However, I don't recommend editing /etc/sudoers since you might break your sudo command (e.g. sudo: /etc/sudoers is owned by uid 501, should be 0
).
Instead, use the keys that don't requre sudo such as cmd_r
and shift
on macOS.
Note
On macOS, if the left keys alt_l
, ctrl_l
, cmd_l
, and shift_l
are not recognized, use their generic counterparts instead: alt
, ctrl
, cmd
, and shift
.
run_examples
utils