TI99 Environment

# CALL_KEY

Syntax

integer-variable=CALL_KEY(keyunit,key,status)

Description

This function scans for a key press on the keyboard. It is TI-99/4A's version of BASIC's INKEY$. Parameters "key" and "status" are unused, they are mandatory to maintain compatibility with TI programs copied directly from other sources. You can place two unused/dummy variables here. A keyunit value of 0 scans the entire keyboard. A keyunit value of 1 scans the left side of keyboard and the gamepad controller's fire button (A button). A keyunit value of 2 scans the right side of keyboard and also the gamepad's fire button (A button). integer-variable and the global variable TIAsc hold the key's ASCII Code (for keyunit 0) or scan code (for key units 1 or 2) of the key pressed. integer-variable can also hold the A-button status of the gamepad controller (key units 1 or 2). If the fire button is pressed on the gamepad, integer-variable and the TIAsc global variable return the value of 18. TIKeyStatus global variable holds the actual key press status of Call_Key (possible return values are -1,0,1). If no key has been pressed TIKeyStatus = 0. If a new key is pressed, TIKeyStatus = 1. If the same key was pressed from a previous call, TIKeyStatus = -1. The same values apply to the gamepad controller's fire button status. Up Arrow key is the equivalent of TI-99's uppercase E = 69 Down Arrow key is the equivalent of TI-99's uppercase X = 88 Left Arrow key is the equivalent of TI-99's uppercase S = 83 Right Arrow key is the equivalent of TI-99's uppercase D = 68

Example Code

    ` Test of call_key - program to move block character left and right using arrow keys
    CALL_CHAR(42,"FFFFFFFFFFFFFFFF")
    ROW = 24 : COL = 12 : speed = 50
    CALL_HCHAR(ROW,COL,42,1) : TI_SYNC()
    mtimer = timer()
    do
        _KEYSCAN:
      k = CALL_KEY(0,K,S)
        If TIKeyStatus = 0 OR ( k <> 68) and ( k <> 83)
            goto _KEYSCAN
        ENDIF
        if timer() > mtimer + speed
            CALL_HCHAR(ROW,COL,32,1)
            if k = 83   ` left
                dec col,1
                if col < 1 then col = maxcols
            else
                if k = 68   ` right
                    inc col,1
                    if col > maxcols then col = 1
                endif
            ENDIF
            CALL_HCHAR(ROW,COL,42,1)
            mtimer = timer()
            TI_SYNC()
        endif
    LOOP

Go back to ...

TI99E Commands Menu
Main Menu

Copyright © Carlos Santiago Lebron - TI99 Environment 2020