Main

 

Getkey

What is getkey?

Getkey is what makes the calculator respond to you pressing a button. You couldn't create any game without it. When you press the left key, and the thing moves on the screen, thats using getkey.

How to use Getkey.
Getkey is a little hard to learn. To start out, select getkey from the prgm menu. Next, press enter to go to the next line. On this line, you need to type in the If command. An example would be:

getkey
If Ans=24
PROGRAMMING
If Ans=26
Then
PROGRAMMING
PROGRAMMING
End

Notice how I used the word Ans. This means the button you pressed (answer). All of the buttons on the calculator have a key value. From the top row of buttons (with ZOOM and Y=) it starts at 11. Y= is 11. Next to it (to the right) is WINDOW, which is 12. Then 13 for ZOOM. Easy, right? Going down, it is 21 for 2nd, 31 for ALPHA, and 41 for MATH. See the pattern? The key values are:

11 12 13 14 15
21 22 23 24 25 26
31 32 33 34 35 36
41 42...
ON is key value 101. The left, right, up, and down keys are, left=24, right=26, down=34, and up is 25.

Now, if you want to make something respond to the press of a button, first find the key value of that button. I will use 2nd, which is 21. The programming would look like this:

Lbl 3
getkey
If Ans=21
Disp "HI
Goto 3

Notice how I put the getkey in a loop? This causes it to not just end. I said 'if I press 2nd, display HI.'
If you want something to move, it's pretty simple. Just chose the button you want to be pressed (I'll use 'left key', which is 24) and enter the rest of the code. My program to make an 'O' move left will look like this:

5->A
7->B
Lbl 5
Output(A,B,"O
getkey
If Ans=24
B-1->B
Goto 5

This will cause B to be subtracted by 1, making it 6 (read the Output( section).

Back to the homepage.