home *** CD-ROM | disk | FTP | other *** search
- program test_KB;
-
- { Demonstates the use of the KB_v02 Unit. }
-
- uses crt, KB_v02;
-
- const on = 'Key is Pressed ';
- off = 'Key isn''t Pressed';
- EveryMsg = 'Any Key to Force ';
- MidMsg = ' Lock Key to ';
-
- lock_keys : array[1..3] of byte =
-
- ( Number_Lock_Key, Caps_Lock_Key, Scroll_Lock_Key );
-
- key_states : array[1..3] of byte =
-
- ( State_On, State_Off, State_Toggle );
-
-
- key_names : array[1..3] of string = ('Number','Caps','Scroll');
- state_names : array[1..3] of string = ('On','Off','Toggle');
-
-
-
- var i,j : byte;
-
- procedure BurnKey;
-
- var ch : char;
-
- begin
-
- ch := readkey;
- if ch = #0 then ch := readkey;
-
- end;
-
- procedure writeAT( x,y : byte; st : string );
-
- begin
-
- gotoxy( x,y );
- write( st );
-
- end;
-
-
- begin
-
- clrscr;
- writeln( 'DEMO of Is_Keypressed Function' );
- writeln;
- writeln( ' Any Normal Key to continue ' );
-
- writeAT( 10, 10, 'Alt Key Status' );
- writeAT( 10, 12, 'CTRL Key Status' );
- writeAT( 10, 14, 'Left Shift Status' );
- writeAT( 10, 16, 'Right Shift Status' );
-
-
- repeat
-
- if Is_Key_Pressed( Alt_Key ) then writeAT( 30,10, on )
- else writeAT( 30,10, off );
-
- if Is_Key_Pressed( Control_Key ) then writeAT( 30,12, on )
- else writeAT( 30,12, off );
-
- if Is_Key_Pressed( Left_Shift ) then writeAT( 30,14, on )
- else writeAT( 30,14, off );
-
- if Is_Key_Pressed( Right_Shift ) then writeAT( 30,16, on )
- else writeAT( 30,16, off );
-
- delay(100);
-
- until keypressed;
-
- clrscr;
-
- burnkey;
- writeln('Keyboard Status Saved' );
- writeln;
-
- Save_Keyboard_Status;
-
- for i := 1 to 3 do begin
-
- for j := 1 to 3 do begin
-
- writeln( EveryMsg, key_names[i], MidMsg, state_names[j] );
- burnkey;
- Set_Keyboard_State( Lock_Keys[i], key_States[j] );
-
- end;
-
- writeln;
-
- end;
-
- writeln;
- writeln( 'End of Demo.' );
- writeln( 'Any Key to Restore Original Lock Status and Exit.' );
-
- BurnKey;
-
- Restore_Keyboard_Status;
-
- end.
-