79301893

Date: 2024-12-22 23:47:24
Score: 1.5
Natty:
Report link

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!

Reasons:
  • Blacklisted phrase (0.5): I cannot
  • Whitelisted phrase (-1.5): You can use
  • RegEx Blacklisted phrase (2.5): please let me know
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Jme