unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Buttons; type TmainForm1 = class(TForm) charLabel1: TLabel; valueLabel2: TLabel; shiftLabel3: TLabel; closeBitBtn1: TBitBtn; Bevel1: TBevel; procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormKeyPress(Sender: TObject; var Key: Char); procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); private { Private declarations } public { Public declarations } end; var mainForm1: TmainForm1; implementation {$R *.dfm} const ctrl_A=1; {ascll value for ctrl+A} ctrl_Z=26;{ascll value for ctrl+Z} functionkeys:array[vk_f1..vk_f12]of string[3]= ('f1','f2','f3','f4','f5','f6','f7','f8','f9','f10','f11','f12'); procedure TmainForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var s:string; begin {show integer key value} valuelabel2.caption:=inttostr(key); {show key shift state} s:=''; if ssShift in Shift then s:=s+'Shift+'; if ssalt in shift then s:=s+'alt+'; if ssctrl in shift then s:=s+'ctrl+'; if length(s)>0 then delete(s,length(s),1); shiftlabel3.Caption:=s; if key in[vk_f1..vk_f12]then charlabel1.Caption:=functionkeys[key] else charlabel1.Caption :=''; if key=vk_space then key:=0; end; procedure TmainForm1.FormKeyPress(Sender: TObject; var Key: Char); begin if ord(key)in[ctrl_A..ctrl_Z]then charlabel1.Caption :=chr(ord(key)+ord('A')-1) else charlabel1.Caption :=key; valuelabel2.Caption :=inttostr(ord(key)); end; procedure TmainForm1.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); begin charlabel1.Caption :=''; valuelabel2.Caption :=''; shiftlabel3.Caption :=''; end; end.