'=========================================================================== ' Subject: MOUSE AND KEY DEMO Date: 05-27-96 (13:08) ' Author: Raymond Joh Code: QB, PDS ' Origin: dslayer@worldnet.att.net Packet: KEYBOARD.ABC '=========================================================================== 'This demo is designed to integrate extended key(as well as normal key) 'functions into mouse routines. Be sure to load with the QB/L switch to 'make use of the Interrupt Calls.Though setup for QuickBasic, this code 'can easily be modified for QB. 'Author : Raymond Joh 'Status : Public Domain '$INCLUDE: 'qb.bi' DECLARE FUNCTION GetKeyBuf$ () DECLARE SUB KeyStroke (keyboard$) DEFINT A-Z '=========================== Demo code(Remove) ============================ COLOR 15, 9 CLS LOCATE 1, 30: PRINT "Mouse and Key Demo" LOCATE 3, 1: PRINT "DEFINED KEYS" PRINT STRING$(12, "Í") PRINT "" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "" PRINT "" PRINT " TO EXIT PROGRAM" PRINT "" PRINT "" PRINT "To define your own keys. Press any key" PRINT "and note the ascii value below.That value will" PRINT "need to be defined in the KeyStroke sub." LOCATE 24, 14: PRINT "ASCII KEY VALUE"; COLOR 0, 7 LOCATE 25, 1: PRINT STRING$(80, " "); '---------------------------- End of Demo Code ---------------------------- DO 'Remove - For demo use only '============ Place the following two lines in your mouse loop ============ keyboard$ = GetKeyBuf$ IF keyboard$ <> "" THEN CALL KeyStroke(keyboard$) LOOP 'Remove - For demo use only END FUNCTION GetKeyBuf$ DIM InRegs AS RegType, OutRegs AS RegType InRegs.ax = &H600 InRegs.dx = &HFF CALL INTERRUPT(&H21, InRegs, OutRegs) ' No character ready if zero flag set IF (OutRegs.flags AND 2 ^ 6) THEN GetKeyBuf$ = "" ELSE IF (OutRegs.ax AND &HFF) <> 0 THEN GetKeyBuf$ = CHR$(OutRegs.ax AND &HFF) ELSEIF (OutRegs.ax AND &HFF) = 0 THEN InRegs.ax = &H600 InRegs.dx = &HFF CALL INTERRUPT(&H21, InRegs, OutRegs) GetKeyBuf$ = CHR$(0) + CHR$(OutRegs.ax AND &HFF) END IF END IF END FUNCTION SUB KeyStroke (keyboard$) IF LEN(keyboard$) = 2 THEN Real.Key% = -ASC(RIGHT$(keyboard$, 1)) ELSE Real.Key% = ASC(keyboard$) END IF '============================== Demo Stuff ============================= LOCATE 25, 50: PRINT "UNDEFINED"; 'Remove - For demo use only LOCATE 25, 20: PRINT Real.Key%; 'Remove - For demo use only '======================= USER DEFINED KEY AREA ========================= IF Real.Key% = -59 THEN LOCATE 25, 50: PRINT " "; 'F1 IF Real.Key% = -61 THEN LOCATE 25, 50: PRINT " "; 'F3 IF Real.Key% = -63 THEN LOCATE 25, 50: PRINT " "; 'F5 IF Real.Key% = 27 THEN SYSTEM 'ESCAPE IF Real.Key% = 13 THEN LOCATE 25, 50: PRINT " "; 'ENTER IF Real.Key% = 9 THEN LOCATE 25, 50: PRINT ""; 'TAB IF Real.Key% = -33 THEN LOCATE 25, 50: PRINT " "; ' IF Real.Key% = -18 THEN LOCATE 25, 50: PRINT " "; ' IF Real.Key% = -35 THEN LOCATE 25, 50: PRINT " "; ' END SUB