如何在按“7”进行除法时检测是否按住shift

How do I detect if shift is held while pressing "7" to make division

我正在尝试制作一个计算器,但我一直运行陷入同样的​​问题。

每次我按 7 它都会运行函数“sevenCmd”,但也会运行“divisionCmd”,即使我没有按住 shift。

我正在使用“键盘”模块

keyboard.add_hotkey('+', lambda: plusCmd())
keyboard.add_hotkey('-', lambda: minusCmd())
keyboard.add_hotkey('*', lambda: timesCmd())
keyboard.add_hotkey('/', lambda: divisionCmd()) #Problems on this line
keyboard.add_hotkey('Enter', lambda: equalsCmd())
keyboard.add_hotkey('C', lambda: clearCmd())
keyboard.add_hotkey(',', lambda: commaCmd())
keyboard.add_hotkey('.', lambda: commaCmd())
keyboard.add_hotkey('Backspace', lambda: deleteCmd())
keyboard.add_hotkey('1', lambda: oneCmd())
keyboard.add_hotkey('2', lambda: twoCmd())
keyboard.add_hotkey('3', lambda: threeCmd())
keyboard.add_hotkey('4', lambda: fourCmd())
keyboard.add_hotkey('5', lambda: fiveCmd())
keyboard.add_hotkey('6', lambda: sixCmd())
keyboard.add_hotkey('7', lambda: sevenCmd())
keyboard.add_hotkey('8', lambda: eightCmd())
keyboard.add_hotkey('9', lambda: nineCmd())
keyboard.add_hotkey('0', lambda: zeroCmd())

只需在division热键中输入一些逻辑来检查是否按下了shift

keyboard.add_hotkey('7 + shift', lambda: divisionCmd()) #Problems on this line

这有效