testkbd.pas 898 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. program TestKBD;
  2. {$X+}
  3. {$IFNDEF OS2}
  4. Sorry, this code is for OS/2 only...
  5. {$ENDIF}
  6. uses
  7. {$IFDEF FPC}
  8. KbdCalls;
  9. {$ELSE}
  10. {$IFDEF VIRTUALPASCAL}
  11. Os2Base;
  12. {$ELSE}
  13. {$IFDEF SPEED}
  14. BseSub;
  15. {$ELSE}
  16. Os2Subs;
  17. {$ENDIF}
  18. {$ENDIF}
  19. {$ENDIF}
  20. function ExtKeyPressed: boolean; (* 'key' is here as well e.g. a shift *)
  21. var
  22. {$IFNDEF VER70} (* patched Borland Pascal *)
  23. KI: KbdKeyInfo;
  24. K: KbdInfo;
  25. {$ELSE}
  26. KI: TKbdKeyInfo;
  27. K: TKbdInfo;
  28. {$ENDIF}
  29. B: boolean;
  30. begin
  31. B := false;
  32. K.cb := SizeOf (K);
  33. KbdGetStatus (K, 0);
  34. KbdPeek (KI, 0);
  35. if (KI.fbStatus and $FE <> 0) or (K.fsState and $FF0F <> 0) then
  36. begin
  37. ExtKeyPressed := true;
  38. if KI.fbStatus and $FE <> 0 then KbdCharIn (KI, IO_NOWAIT, 0);
  39. end else ExtKeyPressed := false;
  40. end;
  41. begin
  42. repeat until not (ExtKeyPressed);
  43. WriteLn (#13#10'Press _any_ key to continue (including shifts etc.) ...');
  44. repeat until ExtKeyPressed;
  45. end.