Apr-02-2021, 09:56 PM
Two problems:
Context; I have made a piano keyboard in tkinter canvas that inputs notes to my program. When I hold shift while clicking the keyboard I want it to be in chord mode. Else it is in melody mode and the music cursor is going to the next position.
- If I use
import keyboard
I get 'ImportError: You must be root to use this library on linux.'. I found already that I need to install keyboard using 'sudo pip3 install keyboard' but after reinstalling using sudo the same problem stays. How to use keyboard without being root/sudo?
- I tried running my app using 'sudo python3 app.py' but my app became incredibly slow. Why? I want to detect if the shift key is pressed when I click the <Button-1>.
if shiftkeypressed: do something
For the shiftkey I use this function:
def shiftkey(): while 1: if keyboard.is_pressed("shift"): shift = 1 else: shift = 0
In another function I can check if shift == 1 and perform a action on that. How would you detect if the shift key is pressed?
Context; I have made a piano keyboard in tkinter canvas that inputs notes to my program. When I hold shift while clicking the keyboard I want it to be in chord mode. Else it is in melody mode and the music cursor is going to the next position.