'=========================================================================== ' Subject: HOTKEYS EXAMPLE Date: Unknown Date (00:00) ' Author: Jeff Shantz Code: QB, QBasic, PDS ' Keys: HOTKEYS,EXAMPLE Packet: KEYBOARD.ABC '=========================================================================== 'Hotkeys Example By Jeff Shantz ' 'Programmer's Note ' 'Many Programmers In QuickBasic Have Wanted To Know How To Have Hotkeys 'In Their Programs For A Long Time But Have Struggled Over It. This 'Example Demonstrates The Incorporation Of Hotkeys Into Your QuickBasic 'Programs. It Uses 2 Main Commands, INKEY$ And ASC. Of Course, There ARE 'Other Ways To Incorporate Hotkeys Into Your Programs But This Technique Is 'A Fast And Easy To Use Way To Use Hotkeys. Hotkeys Improve The Feel Of 'Your Program And Make It More Professional. ' Plays = 0 'sets a variable for maintaining the octave level. See 3 CLS X$ = STRING$(79, 196) 'sets the border as X$ COLOR 7 PRINT X$ 'prints the border LOCATE 23, 1: PRINT X$ 'prints the lower border 'Titles And Instructions COLOR 4: LOCATE 5, 25: PRINT "Hotkey Example" COLOR 14 LOCATE 9, 15: PRINT "[1] Hear 1 Beep" LOCATE 9, 40: PRINT "[2] Hear 2 Beeps" LOCATE 12, 13: PRINT "[M]ake Strange Noise" LOCATE 12, 41: PRINT "[Q]uit Program" LOCATE 18, 24: PRINT "Any Other Key Plays Music" 1 FOR N% = 1 TO 9999 'starts the hotkey loop A$ = INKEY$: IF LEN(A$) = 0 THEN GOTO 2 'program acts upon keypress IF ASC(A$) = 49 THEN BEEP: GOTO 1 'if 1 is pressed, 1 beep is heard IF ASC(A$) = 50 THEN BEEP: BEEP: GOTO 1 'if 2 is pressed, 2 beeps are heard 'in the statement below, if M is pressed, a strange noise is made IF ASC(A$) = 77 THEN PLAY "mf l64 t255 o4 A C E A C E A CE": GOTO 1 IF ASC(A$) = 81 THEN SYSTEM 'exits to dos if run from dos, Q 'in the statement below, if m is pressed, a strange noise is made IF ASC(A$) = 109 THEN PLAY "mf l64 t255 o4A C E A C E A CE": GOTO 1 IF ASC(A$) = 113 THEN SYSTEM ELSE GOTO 3 'exits to dos if run from dos, q 2 NEXT N% GOTO 1 3 IF Plays = 4 THEN PLAY "o4": Plays = 0 'resets the octave level PLAY "mf l12 t255 a c e < a c e" 'plays the music Plays = Plays + 1 'adds another point to the plays variable GOTO 1 'Written by Jeff Shantz ' 'A catalogue of other public domain programming examples and other types of 'public domain software written by Jeff Shantz can be obtained by sending '$2.00 (for shipping & handling) to: ' 'Programming Examples 'c/o Jeff Shantz '162 Ann Street 'Kitchener,Ontario 'N2B 1Y3, CANADA ' 'or by setting your modem to 8,N,1 and calling The Crypt at 1-(519)-576-3127