Support
Quality
Security
License
Reuse
kandi has reviewed key-mapper and discovered the below as its top functions. This is intended to give you an instant insight into key-mapper implemented functionality, and help decide if they suit your requirements.
Get all kandi verified functions for this library.
Get all kandi verified functions for this library.
🎮 An easy to use tool to change the mapping of your input device buttons.
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