Windows 7 是否有一个数字代码来捕获F1按键-112不';行不通

Windows 7 是否有一个数字代码来捕获F1按键-112不';行不通,windows-7,lazarus,Windows 7,Lazarus,我在Windows7上的Lazarus中的文本输入字段上使用按键事件来检测和解释某些键序列,但我想检测F1以弹出一个帮助对话框 我可以捕捉#13作为返回键没有问题,但使用#112似乎无法捕捉F1 我的代码如下: procedure TForm1.keyCatcherKeyPress(Sender: TObject; var Key: char); begin if ( AnsiContainsStr('0123456789',Key) ) then begin

我在Windows7上的Lazarus中的文本输入字段上使用按键事件来检测和解释某些键序列,但我想检测F1以弹出一个帮助对话框

我可以捕捉#13作为返回键没有问题,但使用#112似乎无法捕捉F1

我的代码如下:

procedure TForm1.keyCatcherKeyPress(Sender: TObject; var Key: char);
  begin
    if ( AnsiContainsStr('0123456789',Key) ) then
      begin
        {my processing code}
      end
    else
      if ( Key = #13 ) then
        begin
          {my processing code}
    ... some other key checks that all work fine...
    else
      if ( Key = #112) then
        showHelp();

F1是否可以通过这种方式捕获?这是正确的代码吗?

多亏了特拉玛的指导,我在Lazarus论坛上找到了以下帖子,为我找到了解决方案:

我的按键检测代码现在分为使用
KeyPress
事件检测到的普通字符和使用
OnKeyDown
事件检测到的“特殊”按键

procedure TForm1.keyCatcherKeyPress(Sender: TObject; var Key: char);
  begin
    if ( AnsiContainsStr('0123456789',Key) ) then
      begin
        {my processing code}
      end
    else
    ... some other key checks that all work fine...;


使用
OnKeyDown
事件并测试
VK_F1
按键代码。这同样适用于输入键处理程序(在您的代码中是
#13
分支),您应该将其移动到那里,并测试
VK\u返回
键代码。获取“未找到标识符”VK\u F1。我需要一个额外的用途包括吗?他们应该在lcltype单位。明白了。。。谢谢你的指点。。。这里有一个解释:您是否有可能解释为什么需要以这种方式捕获功能键,但Return似乎是双向的?简单地说,只有当按键产生字符时才会触发
OnKeyPress
事件。F1键不生成字符,而enter键生成(新行馈送)。
      if ( Key = VK_Return ) then
        begin
          {my processing code}
      else
        if ( Key = VK_F1 ) then
          showHelp();