[comp.lang.pascal] How to read the 'dead' key in TP ?

jschippe@cs.ruu.nl (Jeroen Schipper) (01/03/91)

Can anyone tell me how I can check if the '5' on the
numeric keypad has been pressed when numlock is off?

I would also like to know how to read F11 and F12 in
TP.

I am using Turbo pascal 5.5. 

Thanks,

Jeroen.


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
: Jeroen Schipper,     (31)3405-61733 : "Computer programs do what you   :
: Utrecht University, The Netherlands :  tell them to do, not what you   :
: Electronic mail: jschippe@cs.ruu.nl :  want them to do"                :
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ts@uwasa.fi (Timo Salmi) (01/04/91)

In article <4595@ruuinf.cs.ruu.nl> jschippe@cs.ruu.nl (Jeroen Schipper) writes:
>Can anyone tell me how I can check if the '5' on the
>numeric keypad has been pressed when numlock is off?
>
>I would also like to know how to read F11 and F12 in
>TP.

The /pc/ts/tspas22.arc Turbo Pascal units collection at uwasa.fi
archives has a procedure for the latter task. 

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun

zhou@brazil.psych.purdue.edu (Albert Zhou) (01/04/91)

There is a flag in BIOS data area (I forgot the exact address) which 
indicates if numlock is on. Also there is a flag for capslock.

d37703j@taltta.hut.fi (Petteri Stenius) (01/04/91)

In article <4595@ruuinf.cs.ruu.nl> jschippe@cs.ruu.nl (Jeroen Schipper) writes:
>Can anyone tell me how I can check if the '5' on the
>numeric keypad has been pressed when numlock is off?
>
>I would also like to know how to read F11 and F12 in
>TP.
>

You could use interrupt 16H function 10H
to read the scan code from the keyboard.


The following program shows the character and scan code 
read from the keyboard.

uses
  dos;
 
type
  KeyType = record
    ch : byte;
    scan : byte;
  end;
 
procedure GetScan(var result : KeyType);
var
  regs : registers;
begin
  regs.ah := $10;
  intr($16,regs);
  result.scan := regs.ah;
  result.ch := regs.al;
end;
 
var
  ch : KeyType;
 
begin
  repeat
    GetScan(ch);
    writeln(ch.ch:4, ch.scan:4);
  until ch.ch = 27;              { repeats until ESC is pressed }
end.

Pressing '5' on the numpad with numlock on generates ch = 53 and scan = 76
with numlock off you get ch = 0 and scan = 76

F11 gives ch = 0 and scan = 133
F12 gives ch = 0 and scan = 134



>Jeroen.


Petteri