key trapping

 BBS: Inland Empire Archive
Date: 06-22-92 (02:43)             Number: 1078
From: STEVE MATHIESON              Refer#: NONE
  To: BILL CAMPBELL                 Recvd: NO  
Subj: key trapping                   Conf: (2) Quik_Bas
Hi Bill!

 On Sunday June 21 1992, Bill Campbell wrote to Mike
Kruppenbacher, and it went something like this:

 BC> I was messing with it as I went but I figgerred it would work. I put the
 BC> trap in a loop and each time throught the loop it hits
 BC> a "onkey (xx) gosub
 BC> ...". Before the loop I turn the keys off and then
 BC> turn on key (xx). Works
 BC> just fine for the numeric arrows. The code (by the way) works for both
 BC> sets of arrows in (shudder) GWBasic. So, again I
 BC> plead, can anyone help me
 BC> to get the stand-alone arrows to work?     Thanks, Bill C.

Here's an example, although for some reason the dedicated
keypad keys don't work if the NumLock is on....


KEY 15, CHR$(128) + CHR$(75)   'Left Key on extended
KEY 16, CHR$(128) + CHR$(72)   'Up key on extended
KEY 17, CHR$(128) + CHR$(77)   'Right key on extended
KEY 18, CHR$(128) + CHR$(80)   'Down key on extended

' The format is, Key definition, chr$(128) means extended keyboard key
' + (add) the Keys scan code
ON KEY(15) GOSUB dedicatedleft
ON KEY(16) GOSUB dedicatedup
ON KEY(17) GOSUB dedicatedright
ON KEY(18) GOSUB dedicateddown

KEY(15) ON
KEY(16) ON
KEY(17) ON
KEY(18) ON

ON KEY(11) GOSUB numericup
ON KEY(12) GOSUB numericleft
ON KEY(13) GOSUB numericright
ON KEY(14) GOSUB numericdown

KEY(11) ON
KEY(12) ON
KEY(13) ON
KEY(14) ON

DO: LOOP UNTIL INKEY$ = "q"
END

dedicatedleft:
        PRINT " Pressed LEFT on the DEDICATED Arrow Keys"
        RETURN

dedicatedright:
        PRINT " Pressed RIGHT on DEDICATED Arrow keys"
        RETURN
dedicatedup:
        PRINT " Pressed UP on DEDICATED Arrow Keys"
        RETURN
dedicateddown:
        PRINT "Pressed DOWN on DEDICATED arrow Keys"
        RETURN
numericleft:
        PRINT " Pressed LEFT on the NUMERIC Keypad "
        RETURN
numericup:
        PRINT " Pressed UP on NUMERIC pad"
        RETURN
numericdown:
        PRINT " Pressed DOWN on NUMERIC"
        RETURN
numericright:
        PRINT "Pressed RIGHT on NUMERIC Pad"
        RETURN


Hope that helps....

Steve

--- GoldED 2.40
 * Origin:  Sam's Place (613)837-0413 Ottawa, ON Canada (1:163/319)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET