procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var s: string; begin ValueLabel.Caption := IntToStr(Key); //将Key的值转换为字符型 s := ''; //显示组合键状态 if Shift=[ssShift] 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); //清除最后一个+号 ShiftLabel.Caption := s; if Key in [vk_f1 .. vk_f12] then CharLabel.Caption := FunctionKeys[Key] else CharLabel.Caption := ''; //删除旧的字符 if Key = vk_space then Key := 0; end; procedure TMainForm.FormKeyPress(Sender: TObject; var Key: Char); begin if Ord(Key) in [ctrl_A .. ctrl_Z] then CharLabel.Caption := '^' + Chr(Ord(Key) + Ord('A') - 1) else CharLabel.Caption := Key; ValueLabel.Caption := IntToStr(Ord(Key)); end; 有问题请发信息到我的E-mail:[email protected]
ShowMessage(IntToStr(Key));
找 VK_ 开头的.
Shift: TShiftState);
var
s: string;
begin ValueLabel.Caption := IntToStr(Key); //将Key的值转换为字符型
s := '';
//显示组合键状态
if Shift=[ssShift] 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); //清除最后一个+号
ShiftLabel.Caption := s;
if Key in [vk_f1 .. vk_f12] then
CharLabel.Caption := FunctionKeys[Key]
else
CharLabel.Caption := ''; //删除旧的字符 if Key = vk_space then
Key := 0;
end;
procedure TMainForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Ord(Key) in [ctrl_A .. ctrl_Z] then
CharLabel.Caption := '^' + Chr(Ord(Key) + Ord('A') - 1)
else
CharLabel.Caption := Key;
ValueLabel.Caption := IntToStr(Ord(Key));
end;
有问题请发信息到我的E-mail:[email protected]