Recent

Author Topic: OnKey press not fired by arrow keys  (Read 5533 times)

Elmug

  • Hero Member
  • *****
  • Posts: 849
OnKey press not fired by arrow keys
« on: September 05, 2011, 11:28:15 am »
Good people,

I wonder what is the rationale that the OnKey press event is not fired by the arrow keys, or Tab keys.

Thanks for any replies.
« Last Edit: September 05, 2011, 11:31:52 am by Elmug »

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: OnKey press not fired by arrow keys
« Reply #1 on: September 05, 2011, 11:41:18 am »
Making simple application
Code: [Select]
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  caption:=chr(key);
end;
Will show that up arrow says '&'. This would basically mean you can't distinct arrow keys from typed characters with onKeyPress event.

And, how could it represent arrow keys as characters of 0..255? They go from 37..40.
« Last Edit: September 05, 2011, 11:44:18 am by User137 »

Shebuka

  • Sr. Member
  • ****
  • Posts: 429
Re: OnKey press not fired by arrow keys
« Reply #2 on: September 05, 2011, 12:20:44 pm »
Good people,

I wonder what is the rationale that the OnKey press event is not fired by the arrow keys, or Tab keys.

Thanks for any replies.
They are fired, (because i'm currently intercept then in a TMemo for example) and you can check them with VK_Up or VK_Down ecc.
Where do you assign your OnKeyPress, wich component/widget/os?


Edit: My fault, you are right, it's OnKeyDown that is fired because OnKeyPress of a Arrow Keys has no sense, arrow is not related with any Char Key.
« Last Edit: September 05, 2011, 04:43:35 pm by Shebuka »

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: OnKey press not fired by arrow keys
« Reply #3 on: September 05, 2011, 03:46:05 pm »
They're not firing up in onKeyPress using 32-bit Win7. onKeyDown works though.

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: OnKey press not fired by arrow keys
« Reply #4 on: September 05, 2011, 03:55:01 pm »
They're not firing up in onKeyPress using 32-bit Win7. onKeyDown works though.

Thanks. My first thought was that they are not printing characters, as User137 implies. But then I wondered why that would be so, if Key is Key and those are keys.

I'll try OnKeyDown, with the explanations given.

Thanks!

 

TinyPortal © 2005-2018