🗒 Cheat Sheet← Lesson
BitWithBite
Pygame Mastery Worksheet

🎮 User Input

Module 5 of 20 · Level ★☆☆ · Time: 30 min
SCORE___ / 20
NameClassDate
After this worksheet you can
Handle KEYDOWN/KEYUP eventsUse key.get_pressed() for smooth movementDetect mouse clicks and positionImplement basic mouse dragging
📚 Quick Recap

Pygame input splits into discrete events (KEYDOWN, MOUSEBUTTONDOWN) for one-shot actions, and continuous polling (pygame.key.get_pressed()) for smooth held-key movement — mixing these up is the most common input bug.

🧠 Section A · Concept Check ● BEGINNER 4 × 1 = 4

1Which tool is correct for smooth continuous movement?
2What does event.button == 1 mean on MOUSEBUTTONDOWN?
3Which event type fires once per key press, not continuously?
4What does pygame.mouse.get_pos() return?

🧮 Section B · Problem Solving ● INTERMEDIATE 2 + 3×3 = 11

5To use jump only once per press, check for the event, not held state.
6Scroll wheel motion is read from the event's .y attribute.
7Write the two-line pattern to move a player left when the LEFT arrow key is held.
8Describe the 3-step pattern for implementing mouse dragging of an object.
9Why would using KEYDOWN instead of key.get_pressed() make movement feel jerky?

🚀 Section C · Challenge ● CHALLENGE 5

10A player needs to move diagonally when holding both UP and RIGHT. Explain how key.get_pressed() naturally supports this where a single KEYDOWN check would not.
💭 Reflection — the most useful thing I learned:
A ___/4   B ___/11   C ___/5   Total ___/20 Teacher's Signature Parent's Signature
✂ answer key — fold or cut before handing out

1-B   2-B   3-A   4-B  |  5 KEYDOWN   6 MOUSEWHEEL   7 = keys = pygame.key.get_pressed() then if keys[pygame.K_LEFT]: player.x -= speed   8 = set dragging=True on MOUSEBUTTONDOWN over the object, update its position on MOUSEMOTION while dragging is True, set dragging=False on MOUSEBUTTONUP   9 = KEYDOWN only fires once per press, so movement would happen in single sudden jumps rather than smoothly every frame while the key stays held  |  10 = key.get_pressed() returns the held state of EVERY key each frame, so you can check both K_UP and K_RIGHT simultaneously and apply both movements in the same frame — a single KEYDOWN event only reports one key press at a time

📄 Need offline practice?Download the print-ready PDF or open the one-page cheat sheet.
⬇ Worksheet PDF 🗒 Cheat Sheet