?? main.pas
字號(hào):
unit Main;
interface
uses
Windows, SysUtils, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Buttons, StdCtrls, ExtCtrls;
type
TMainForm = class(TForm)
Label2: TLabel;
CharLabel: TLabel;
Label3: TLabel;
Label4: TLabel;
ValueLabel: TLabel;
ShiftLabel: TLabel;
Bevel1: TBevel;
Bevel2: TBevel;
Bevel3: TBevel;
Label1: TLabel;
Bevel4: TBevel;
Bevel5: TBevel;
Bevel6: TBevel;
Bevel7: TBevel;
CloseButton: TBitBtn;
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
public
end;
var
MainForm: TMainForm;
implementation
{$R *.DFM}
const
ctrl_A = 1; //Ctrl+A 組合鍵的ASCII值
ctrl_Z = 26; //Ctrl+Z組合鍵的ASCII值
FunctionKeys: array [vk_f1 .. vk_f12] of string[3] =
('F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8',
'F9', 'F10', 'F11', 'F12');
procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
s: string;
begin
ValueLabel.Caption := IntToStr(Key); //將Key的值轉(zhuǎn)換為字符型
s := '';
//顯示組合鍵狀態(tài)
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); //清除最后一個(gè)+號(hào)
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;
procedure TMainForm.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
//釋放按鍵后清空各個(gè)顯示框
CharLabel.Caption := '';
ValueLabel.Caption := '';
ShiftLabel.Caption := '';
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -