Pygame knowing when shift+other key is pressed

后端 未结 2 428
野性不改
野性不改 2021-01-22 05:21

I am trying to create a program similar to Microsoft word, only heavily simplified. I need to be able to know when shift+(any key) is pressed, and display the proper value for w

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-22 06:10

    src = r"`1234567890-=qwertyuiop[]\asdfghjkl;\'zxcvbnm,./"
    dest = r'~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?'
    ch = chr(event.key)
    pressed = py.key.get_pressed()
    if pressed[py.K_RSHIFT] or pressed[py.K_LSHIFT] and ch in src:
        ch = dest[src.index(ch)]
    

提交回复
热议问题