unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    cmbSpace: TButton;
    Timer1: TTimer;
    cmbRCtrl: TButton;
    cmbRAlt: TButton;
    cmbEnter: TButton;
    cmbRShift: TButton;
    cmbUp: TBitBtn;
    cmbRight: TBitBtn;
    cmbDown: TBitBtn;
    cmbLeft: TBitBtn;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
var
  buttons: TKeyBoardstate;
begin
  //Получаем состояния кнопок клавиатуры
  GetKeyboardState(buttons);
  //Отобразим состояния кнопок клавиатуры
  //..пробел
  if buttons[VK_SPACE] and 128 <> 0 then
    SendMessage(cmbSpace.Handle, BM_SETSTATE, BST_CHECKED, 0)
  else
    SendMessage(cmbSpace.Handle, BM_SETSTATE, BST_UNCHECKED, 0);
  //..enter
  if buttons[VK_RETURN] and 128 <> 0 then
    SendMessage(cmbEnter.Handle, BM_SETSTATE, BST_CHECKED, 0)
  else
    SendMessage(cmbEnter.Handle, BM_SETSTATE, BST_UNCHECKED, 0);
  //..правый Ctrl
  if buttons[VK_RCONTROL] and 128 <> 0 then
    SendMessage(cmbRCtrl.Handle, BM_SETSTATE, BST_CHECKED, 0)
  else
    SendMessage(cmbRCtrl.Handle, BM_SETSTATE, BST_UNCHECKED, 0);
  //..правый Alt
  if buttons[VK_RMENU] and 128 <> 0 then
    SendMessage(cmbRAlt.Handle, BM_SETSTATE, BST_CHECKED, 0)
  else
    SendMessage(cmbRAlt.Handle, BM_SETSTATE, BST_UNCHECKED, 0);
  //..правый Shift
  if buttons[VK_RSHIFT] and 128 <> 0 then
    SendMessage(cmbRShift.Handle, BM_SETSTATE, BST_CHECKED, 0)
  else
    SendMessage(cmbRShift.Handle, BM_SETSTATE, BST_UNCHECKED, 0);
  //..вверх
  if buttons[VK_UP] and 128 <> 0 then
    SendMessage(cmbUp.Handle, BM_SETSTATE, BST_CHECKED, 0)
  else
    SendMessage(cmbUp.Handle, BM_SETSTATE, BST_UNCHECKED, 0);
  //..вниз
  if buttons[VK_Down] and 128 <> 0 then
    SendMessage(cmbDown.Handle, BM_SETSTATE, BST_CHECKED, 0)
  else
    SendMessage(cmbDown.Handle, BM_SETSTATE, BST_UNCHECKED, 0);
  //..влево
  if buttons[VK_LEFT] and 128 <> 0 then
    SendMessage(cmbLeft.Handle, BM_SETSTATE, BST_CHECKED, 0)
  else
    SendMessage(cmbLeft.Handle, BM_SETSTATE, BST_UNCHECKED, 0);
  //..вправо
  if buttons[VK_RIGHT] and 128 <> 0 then
    SendMessage(cmbRight.Handle, BM_SETSTATE, BST_CHECKED, 0)
  else
    SendMessage(cmbRight.Handle, BM_SETSTATE, BST_UNCHECKED, 0);
end;

end.
