[comp.lang.pascal] Changing NumLock key status with TP3.0

CROWTHER@cambridg.csc.ibm.com (Nancy Crowther) (08/03/88)

I have used the following code to press and release Num Lock from
within a program (under Turbo 3):

(***********************************************************************
 * Routine: PressNumLock
 * Purpose: Sets Num Lock key.
 **********************************************************************)
procedure PressNumLock;

const
  NUMLOCK = $20;

var
  Keystatus: byte absolute $0040:$0017;  (* keyboard status byte 1 *)

begin
  Keystatus := Keystatus OR NUMLOCK;
end;

(***********************************************************************
 * Routine: ReleaseNumLock
 * Purpose: Releases Num Lock key.
 **********************************************************************)
procedure ReleaseNumLock;

const
  NUMLOCKOFF = $DF;

var
  Keystatus: byte absolute $0040:$0017;  (* keyboard status byte 1 *)

begin
  Keystatus := Keystatus AND NUMLOCKOFF;
end;

Nancy Crowther

d87-jse@nada.kth.se (Joakim Sernbrant) (08/04/88)

This probably works, but it really messes things up when there
is a NumLock LED on the keyboard (most of them nowdays). The
LED is lit/unlit by latch in the keyboard, I believe.

/JockeS