keyboard
Read the calculator’s keys.
Choosing a method
read()waits for a key, which suits menus and prompts.get()returns at once, which suits a loop that keeps running without input.is_down()tests a held key, and several keys can be held together, which suits games.
from ti84 import keyboard
while not keyboard.is_down(keyboard.CLEAR):
x += keyboard.is_down(keyboard.RIGHT) - keyboard.is_down(keyboard.LEFT)
Methods
- read() int
Wait for a key press and return its code.
- Targets:
CE, Classic, Flash App
z = keyboard.read()
- get() int
Return the pressed key’s code, or 0 at once if none. Use this in game loops.
- Targets:
CE, Classic, Flash App
z = keyboard.get()
- is_down(key) bool
Whether a key is held now; several keys can be held together.
- Targets:
CE, Classic, Flash App
z = keyboard.is_down(keyboard.UP)
Key constants
Names also work in lower case and with a KEY_ prefix, so keyboard.enter and
keyboard.KEY_ENTER both mean keyboard.ENTER. Digit keys need the prefix, as in
keyboard.KEY_5.
Constant |
Scan code |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|