Support
Quality
Security
License
Reuse
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here
Get all kandi verified functions for this library.
Remap device keys based on currently-focused window title
QUESTION
How do I detect if shift is held while pressing "7" to make division
Asked 2022-Apr-16 at 10:35I am trying to make a calculator, but I keep running into the same issue.
Every time I press 7 it runs the function "sevenCmd" but also "divisionCmd" even tho I'm not holding shift.
I am using the "keyboard" module
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())
ANSWER
Answered 2022-Apr-16 at 10:35Just put in some logic in the division
hotkey to check whether or not shift is pressed
keyboard.add_hotkey('7 + shift', lambda: divisionCmd()) #Problems on this line
this works
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Find more information at:
Save this library and start creating your kit
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source