You can use get_key(key)
! However, you need to first import the System Module (named ti_system
).
get_key can be run without a parameter to output a string corresponding with the key pressed (pressing 1 outputs "1", pressing escape outputs "esc", etc.).
If you use a parameter in get_key, it will delay program execution until that key is pressed. For example, get_key("5")
will wait until the 5 key is pressed before running the program.
For example, if you wanted to create an infinite loop that runs until the user presses escape, you would run
from ti_system import *
while (get_key() != "esc"):
# run code here
You can also get mouse coordinates using get_mouse()
.
You can see the full documentation for the ti_system module here https://education.ti.com/html/webhelp/EG_TINspire/EN/Subsystems/EG_Python/Content/m_menumap/mm_tisystem.HTML
Yeah... Unfortunately TI doesn't have particularly good documentation. As an aside, I was not able to get print("key: "+get_key())
to work properly, despite get_key working fine in comparisons such as get_key() == "esc"
, for some reason? This might just be poor code on my part, but this does mean I cannot provide a list of the key strings to specific keys like TIBasic has. If anyone reading this managed to get this to work properly, please let me know!