TURBO PASCAL

Новости

Программы   

Turbo Pascal 

Игры

Документация   

Странности

FAQ

Ссылки

Форум

Гостевая книга

Рассылка

Благодарности

Об авторе

65: How can I detect if the shift/ctrl/alt etc key is pressed? I
know how to get the scan codes with the ReadKey function, but I
can't find the procedure for detecting these keys.

 A: Detecting pressing 
the special keys or getting the toggle status
cannot be done with ReadKey. You'll need to access the 
Keyboard
Flags Byte at $0040:$0017. You can do this either by a direct 
"Mem"
access, or using interrupt $16 function $02. For more details
including the bitfields for the shift flags see in Ralf Brown's
interrupt list ftp://garbo.uwasa.fi/pc/programming/inter46a.zip (or
whatever is the current version). For example to see if the alt key
is pressed you can use
  uses Dos;
  function ALTDOWN : boolean;
  var regs : registers;
  begin
    FillChar (regs, SizeOf(regs), 0);
    regs.ah := $02;
    Intr ($16, regs);
    altdown := (regs.al and $08) = $08;
  end;
For the enhanced keyboard flags see interrupt $16 function $12. It
can distinguish also between the right and the left alt and ctlr
keys.
   A tip from Martijn Leisink martijnl@sci.kun.nl. Be careful [if
you use the $0040:$0017 memory position to set a toggle]: On 
several
computers you have to call int 16h after the new setting is shown by
the LED's on the keyboard. Not doing so might give the user 
wrong
information.
   A tip from Dr John Stockton jrs@dclf.npl.co.uk. Going via a
BytePointer set to Ptr(Seg0040, $0017) is almost as easy as 
"Mem",
and also works in Protected mode.
 

 Contents

На первую страницу

Rambler's Top100 Rambler's Top100
PROext: Top 1000

(с)Все права защищены

По всем интересующим вопросам прошу писать на электронный адрес

Hosted by uCoz