请教各位:如何检测到键盘发出的控制字符?

xfwf 2002-11-19 06:54:21
我向请问如何接收到键盘发出的控制字符,比如上下左右键,退格键等等,
就好像汇编中检测键盘的扫描码一样,谢谢
...全文
52 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
智商无下限 2002-11-21
  • 打赏
  • 举报
回复
你在窗体的ONKEYDOWN事件写
showmessage(inttostr(KEY));
运行后自己看!呵呵。。。。
wangchinaking 2002-11-20
  • 打赏
  • 举报
回复
GetAsyncKeyState (int vKey // virtual-key code
);
它可以,试试吧。
weibz0525 2002-11-20
  • 打赏
  • 举报
回复
楼上的还不全吗?
oracle_lover 2002-11-19
  • 打赏
  • 举报
回复
vk_LButton = $01;
vk_RButton = $02;
vk_Cancel = $03;
vk_MButton = $04; { NOT contiguous with L & RBUTTON }
vk_Back = $08;
vk_Tab = $09;
vk_Clear = $0C;
vk_Return = $0D;
vk_Shift = $10;
vk_Control = $11;
vk_Menu = $12;
vk_Pause = $13;
vk_Capital = $14;
vk_Escape = $1B;
vk_Space = $20;
vk_Prior = $21;
vk_Next = $22;
vk_End = $23;
vk_Home = $24;
vk_Left = $25;
vk_Up = $26;
vk_Right = $27;
vk_Down = $28;
vk_Select = $29;
vk_Print = $2A;
vk_Execute = $2B;
vk_SnapShot = $2C;
vk_Copy = $2C not used by keyboards }
vk_Insert = $2D;
vk_Delete = $2E;
vk_Help = $2F;
vk_A thru vk_Z are the same as their ASCII equivalents: 'A' thru 'Z' }
vk_0 thru vk_9 are the same as their ASCII equivalents: '0' thru '9' }
vk_NumPad0 = $60;
vk_NumPad1 = $61;
vk_NumPad2 = $62;
vk_NumPad3 = $63;
vk_NumPad4 = $64;
vk_NumPad5 = $65;
vk_NumPad6 = $66;
vk_NumPad7 = $67;
vk_NumPad8 = $68;
vk_NumPad9 = $69;
vk_Multiply = $6A;
vk_Add = $6B;
vk_Separator = $6C;
vk_Subtract = $6D;
vk_Decimal = $6E;
vk_Divide = $6F;
vk_F1 = $70;
vk_F2 = $71;
vk_F3 = $72;
vk_F4 = $73;
vk_F5 = $74;
vk_F6 = $75;
vk_F7 = $76;
vk_F8 = $77;
vk_F9 = $78;
vk_F10 = $79;
vk_F11 = $7A;
vk_F12 = $7B;
vk_F13 = $7C;
vk_F14 = $7D;
vk_F15 = $7E;
vk_F16 = $7F;
vk_F17 = $80;
vk_F18 = $81;
vk_F19 = $82;
vk_F20 = $83;
vk_F21 = $84;
vk_F22 = $85;
vk_F23 = $86;
vk_F24 = $87;
vk_NumLock = $90;
vk_Scroll = $91;
xfwf 2002-11-19
  • 打赏
  • 举报
回复
顺便请问 killlaoli(菜鸟) 老兄:
关于 VK_UP 等这些字符值在那可以查到,又或者你能否提供一份很全的表给我
killlaoli 2002-11-19
  • 打赏
  • 举报
回复
设置主窗体的keypreview属性为true,然后在onkeydown中加入形如:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key = VK_UP then
begin
// Do Something
end;
if key = VK_DOWN then
begin
// Do Something
end;
........................
end;

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧