Hardware Delphi

Title: Shift, Ctrl, Alt, Scroll lock, Num lock, Caps lock, Insert Checking
Question: How to check if Shift, Ctrl, Alt, Scroll lock, Num lock, Caps lock, Insert is pressed?
Answer:
function check(key:integer):boolean;
var x,pag:byte;
begin
result:=false;
asm
mov ah,2h
int 16h
mov x,al
end;
sleep(1);
pag:=0;
while x 0 do
begin
if pag=key then if ((x and $80) shr 7)=1 then result:=true;
inc(pag);
x:=x shl 1;
end;
end;
{
Posible key values:
0-Insert active
1-Caps lock
2-Num lock
3-Scroll lock
4-Alt
5-Ctrl
6-Left shift
7-Right shift
The following example demonstrates checking if the
Alt key is pressed during a Button Click.
if check(4) then showmessage('Alt key was pressed')
else showmessage('Alt key wasn't pressed');
}