TBasic for Dummies
Lesson 7 |
Getkey is probably one of the best commands for making games on the TI-82. It allows you to see what button the user hits. It's also fairly simple to use (If you have your manual). We will work with the example below.
Program Hi:
:lbl 1
:Getkey->K
:if K=105
:Then
:Disp "hi"
:End
:Goto 1
Getkey will capture the key that is pressed...
It won't wait for a key to be pressed so you have to loop it to check if
a key is pressed. If a key ISN'T pressed it will return 0 as a value. Each
key on the calculator has a set value (this is where you will need your
book). On page 13-16 there is a chart of each keys value. You can use that
and the If-Then statement to test to see what key is pressed. So for those
of you who haven't tested the above program, everytime you hit enter (key
105) it will put HI on the screen. Another example of a cute small program!