TURBO PASCAL

Новости

Программы   

Turbo Pascal 

Игры

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

Странности

FAQ

Ссылки

Форум

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

Рассылка

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

Об авторе

78: How do I detect if the F11 or F12 key has been pressed?

 A: Here is a sample 
program
  uses Dos;
  (* Enhanced keyboard ReadKey, no Crt unit needed. Detects 
also F11
     and F12, and distinguishes between the numeric keypad and 
the
     gray keys. Lower part of the word returns the first scan code,
     the higher part the second *)
  function RDENKEFN : word;
  var regs     : registers;
      keyboard : byte absolute $40:$96;
  begin
    rdenkefn := 0;
    if ((keyboard shr 4) and 1) = 0 then exit;
    FillChar (regs, SizeOf(regs), 0);
    regs.ah := $10;
    Intr ($16, regs);
    rdenkefn := regs.ax;
  end;  (* rdenkefn *)
  {}
  procedure TEST;
  var key : word;
  begin
    while Lo(key) <> 27 do  { esc exits }
      begin
        key := RDENKEFN;
        if (Lo(key) = 0) and (Hi(key) = 133) then
          writeln ('F11 was pressed');
        if (Lo(key) = 0) and (Hi(key) = 134) then
          writeln ('F12 was pressed');
      end;
  end;
  {}
  begin TEST; end.
 

 Contents

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

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

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

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

Hosted by uCoz