I have looked at as many functions as I can and I still can't find one that lets you intercept the click of a TI arrow key click.
-
1Can you please provide the TI model number? Are you coding in Basic or Assembly? – Abboq Aug 03 '11 at 18:09
-
It is an 83-silver and I am programming in whatever you use when you press the prog button. – Jackelope11 Aug 03 '11 at 19:16
3 Answers
For Basic programs, which are run with the "Prog" button, you'll need to call getKey
, which returns a key code for the last button pressed. The arrow buttons are mapped to codes 24
, 25
, 26
, and 34
.
More information is available at TI-Basic Developer, underneath the heading "Reading Keypresses".

- 1,101
- 1
- 10
- 21
-
Thank you for the great answer. I have looked into this for a while and I appreciate the answer. – Jackelope11 Aug 17 '11 at 01:35
I know this is an old question, but I think this point might still be relevant.
If you are using the key input to move a character, or shift a value somehow, you are almost always better off avoiding if-then-else
statements.
The fastest method is usually to do something like this:
:getkey -> A
:X+(A=24) -> X
:X-(A=26) -> X
:Y+(A=25) -> Y
:Y-(A=34) -> Y
which can be further condensed to:
:getkey -> A
:X+(A=24)-(A=26) -> X
:Y+(A=25)-(A=34) -> Y
Instead of dealing with the logic through the if
statements, we utilize the fact that the (A=24)
has a 'boolean' (0 or 1) value. So we add or subtract 1 if it is a certain value.
Setting limits is also fairly easy:
:getkey -> A
:X+(A=26)(X<=20)-(A=24)(X>0) -> X
:Y+(A=25)(Y<=15)-(A=34)(Y>=3) -> Y
So if (X<20)
it will multiply by 1, but when X>=20, (X<20)
will multiply by 0, negating the incriment.
I use another technique to help with selecting values in some of my programs: The left and right keys increment and decrement a variable by a different value than the up and down keys do. However, it requires some more logic.
:getkey -> A
:X+10(A=26)(X+10<=100)-10(A=24)(X-10>=0) -> X
:Y+(A=25)(Y<15)-(A=34)(Y>3) -> B
In this case, the left and right arrows go by tens, and the up and down go by ones. (X+10<=100)
is used instead of (X<100)
because the latter will be true if X=99
so X can go up to 109. The former makes sure that adding ten will not exceed the limit.

- 1,010
- 1
- 11
- 25
You should be able to do it with the getkey command.
getkey (Store as) (Variable) A
while A=0
getkey (Store as) A
Then you can recall the variable A throughout the program. Each key has a number that is called through the getkey command. So you can use that variable by,
If A = 25
...
If A != 25
...
(25 would be the up arrow)

- 31
- 3