From c0552edaf352d507812b8b171cb78eb5649a2f77 Mon Sep 17 00:00:00 2001 From: Keith Smith Date: Wed, 28 Jan 2026 17:31:45 -0700 Subject: [PATCH] Fix keyboard input recognition for special keys and cross-platform modifiers - Add explicit handling for backspace, delete, escape, and space keys - Fix modifier key mappings to work correctly on Linux/Windows (Ctrl key was incorrectly mapped to 'cmd') - Add platform detection for proper modifier key handling across macOS, Linux, and Windows Co-Authored-By: Claude Sonnet 4.5 --- MSMD_multiLevel.py | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/MSMD_multiLevel.py b/MSMD_multiLevel.py index 79cecf9..956415b 100644 --- a/MSMD_multiLevel.py +++ b/MSMD_multiLevel.py @@ -108,7 +108,15 @@ class GraphicsView(QGraphicsView): textFromCode = 'enter' elif code == 16777217: textFromCode = 'tab' - else: + elif code == 16777219: + textFromCode = 'backspace' + elif code == 16777223: + textFromCode = 'delete' + elif code == 16777216: + textFromCode = 'esc' + elif code == 32: + textFromCode = 'space' + else: textFromCode = chr(code) except : textFromCode = text @@ -130,10 +138,16 @@ class GraphicsView(QGraphicsView): if(pressedModifiers & Qt.AltModifier): modifierTextList.append('alt') if(pressedModifiers & Qt.ControlModifier): - modifierTextList.append('cmd') # on the mac this is the command key + if sys.platform == 'darwin': # macOS + modifierTextList.append('cmd') # on the mac this is the command key + else: # Linux and Windows + modifierTextList.append('ctrl') if(pressedModifiers & Qt.MetaModifier): - modifierTextList.append('ctrl')# on the mac this is the control key - + if sys.platform == 'darwin': # macOS + modifierTextList.append('ctrl') # on the mac this is the control key + else: # Linux and Windows + modifierTextList.append('win') + return modifierTextList @@ -629,11 +643,15 @@ class App(QWidget): if(pressedModifiers & Qt.AltModifier): modifierTextList.append('alt') if(pressedModifiers & Qt.ControlModifier): - #modifierTextList.append('ctrl') - modifierTextList.append('cmd') # on the mac this is the command key + if sys.platform == 'darwin': # macOS + modifierTextList.append('cmd') # on the mac this is the command key + else: # Linux and Windows + modifierTextList.append('ctrl') if(pressedModifiers & Qt.MetaModifier): - modifierTextList.append('ctrl')# on the mac this is the control key - #modifierTextList.append('win') + if sys.platform == 'darwin': # macOS + modifierTextList.append('ctrl') # on the mac this is the control key + else: # Linux and Windows + modifierTextList.append('win') return set(modifierTextList) == set(self.currentInputModifiers) def simplifyModifierList(self, modifierList):