如何捕获键盘上的左右上下键?(50分)

  • 主题发起人 greenhand2003
  • 开始时间
G

greenhand2003

Unregistered / Unconfirmed
GUEST, unregistred user!
如何捕获键盘上的左右上下键?
我是菜鸟,请给出几行代码。谢谢
 
在KeyDown事件中
if key = 上下箭头的键值 then
......
 
查查ASSCII码表吧!!
 
方向键要在keydown事件中用如下代码响应:
case key of
VK_UP:showmessage('up key');
VK_DOWN:showmessage('down key');
VK_LEFT:showmessage('left');
VK_RIGHT:showmessage('right');
end;
 
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
showmessage(inttostr(key));
end;
 
有ASSCII表呀
 
左上右下:37,38,39,40
 
谢谢各位
 
顶部 底部