detecting keys

 BBS: Inland Empire Archive
Date: 11-12-92 (16:50)             Number: 326
From: JOHN GALLAS                  Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: detecting keys                 Conf: (2) Quik_Bas
Heres some code that'll check for control/alt/left & right
shift/numlock/caps/scroll lock and print them in bright white
if they're on.

'0:1047 is the ctrl/shift/alt/caps/scroll/num byte.
DEFINT A-Z

CLS

DO
  DEF SEG = 0
  a = PEEK(1047)
  LOCATE 1, 1
 level = 0
  IF a AND 1 THEN COLOR 15, 0  'if right shift is down
  PRINT "RSHFT ";
  COLOR 7, 0
  IF a AND 2 THEN COLOR 15, 0  'if left shift is down
  PRINT "LSHFT ";
  COLOR 7, 0
  IF a AND 4 THEN COLOR 15, 0 'if control is down
  PRINT "CTRL ";
  COLOR 7, 0
  IF a AND 8 THEN COLOR 15, 0 'if alt is down
  PRINT "ALT ";
  COLOR 7, 0
  IF a AND 16 THEN COLOR 15, 0 'if scroll lock is on
  PRINT "SCRL ";
  COLOR 7, 0
  IF a AND 32 THEN COLOR 15, 0 'if num lock is on
  PRINT "NUM ";
  COLOR 7, 0
  IF a AND 64 THEN COLOR 15, 0 'if caps lock is on.
  PRINT "CAPS ";
  COLOR 7, 0
  dummy$ = INKEY$  'so it doesn't start beeping if you hit too many keys
LOOP


 * OLX 2.1 TD * Two blondes in a Volkswagon: Farfromthinkin
--- RyPacker v2.5a
 * Origin: The Ghost Mode - An RyBBS System!  (612)-688-0026 (1:282/3006)
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