Summary of What Needs to be Done
The handle_keypress method in games/2048-Game/2048-Game.py uses event.keysym.lower() which throws a TypeError when arrow keys are pressed (since arrow key keysyms like Up, Down contain non-lowercase characters and may not have len() == 1). The current conditional if len(event.keysym) == 1 is insufficient — arrow key keysyms have length > 1, so they fall through to the move_map lookup and raise a KeyError.
Changes that Need to be Made
- In
handle_keypress, directly check if event.keysym is in move_map without the faulty .lower() call that causes TypeError for arrow keys
- Ensure arrow keys and WASD both work correctly
Impact that it would Provide
- Fixes crashes when pressing arrow keys in the 2048 game
- Improves keyboard accessibility for the game
Note: Please assign this issue to the tmdeveloper007 account.
Summary of What Needs to be Done
The
handle_keypressmethod ingames/2048-Game/2048-Game.pyusesevent.keysym.lower()which throws aTypeErrorwhen arrow keys are pressed (since arrow key keysyms likeUp,Downcontain non-lowercase characters and may not havelen() == 1). The current conditionalif len(event.keysym) == 1is insufficient — arrow key keysyms have length > 1, so they fall through to themove_maplookup and raise a KeyError.Changes that Need to be Made
handle_keypress, directly check ifevent.keysymis inmove_mapwithout the faulty.lower()call that causes TypeError for arrow keysImpact that it would Provide
Note: Please assign this issue to the
tmdeveloper007account.