如何在KeyDown事件中判断 up 或 down 这两 个键??????????就是在 KeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);  如何判断 是否 按了 up 或 down 这两个键???

解决方案 »

  1.   

    Form1.keypreview:=true;procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if key=33 then showmessage('up');
      if key=34 then showmessage('down');
    end;
      

  2.   

    不用消息,一楼的对,KeyDown过程本身就提供了键码识别。
      

  3.   

    直接使用虚拟键就是,不用具体比较它的ASCII值。主FORM的keypreview属性要为trueprocedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
     if Shift>=[ssalt]// and (activecontrol.Name='button1')
    then  if key=VK_UP then
          begin
            activecontrol.Top:=activecontrol.top-10;
          end;
    end;
      

  4.   

    http://community.csdn.net/Expert/topic/3137/3137513.xml?temp=.7491724