Liberty BASIC Help Online

Using Inkey$
Liberty BASIC has a special variable named Inkey$ which can be used to fetch keys pressed.  This only works with the graphicbox and with windows opened for graphics.  Graphics controls handle an event called characterInput, which copies pressed-key codes into the Inkey$ variable.  See Graphics Commands, Inkey$ , Reading Mouse Events and Keystrokes, and Using Virtual Key Contants with Inkey$ for more details.  Here is a very short program demonstrating Inkey$:
    'Inkey$ example
    print "Keys pressed:"
    open "Inkey$ example" for graphics as #graph
    print #graph, "when characterInput [keyPressed]"
    print #graph, "trapclose [quit]"
    'make sure #graph has input focus
    print #graph, "setfocus"
    'scan for events
    goto [loopHere]
    key$ = Inkey$
    if len(key$) < 2 then
        print "pressed: "; key$
        print "Unhandled special key"
    end if
    goto [loopHere]
    print "Quitting"
    close #graph

Copyright (C) 2003 Shoptalk Systems
Liberty BASIC -