Python Keyboard Listener & Get Hotkeys?

Is it possible to listen for Keyboard input via a Python plugin?

For example, if I press the ‘d’ key, then I want the script to trigger a specific action.

Also, is it possible to get the currently set hotkeys of the Krita instance?

I tried using from pynput import keyboard, and assigning listener = keyboard.Listener(listenerFunc=listenerFunc), but whenever I run listener.start(), Krita crashes and I have to force close it.

Actions are basically those things that you can trigger using a hotkey, so instead of thinking of keyboard listeners, you should just use actions directly. You can look at “hello” script that is available by default in Krita, if you enable it, you can set up a shortcut in Configure Krita -> keyboard Shortcuts.

You could even set up a default shortcut for the action in an .action file. For that it would be best to check out 10 brushes script (also available by default).

Oh okay, gotcha. I’ll play around with that then. Thanks Tiar!