Recent

Author Topic: [Solved] How to detect unicode characters in KeyPress event?  (Read 1003 times)

loaded

  • Hero Member
  • *****
  • Posts: 825
[Solved] How to detect unicode characters in KeyPress event?
« on: January 06, 2022, 01:11:49 pm »
Hi All,
When I try to use the following code in the KeyPress event of the form;
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);
  2. begin
  3.   Caption:=Key; // ÇĞİŞÜÖ--> ?
  4. end;
For unicode characters I get the character ?.

In the KeyDown event, I get the numeric number of the key directly.
Can I solve this without dealing with numeric numbers, that is, without entering the KeyDown event?
« Last Edit: January 06, 2022, 01:28:24 pm by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

PascalDragon

  • Hero Member
  • *****
  • Posts: 5481
  • Compiler Developer
Re: How to detect unicode characters in KeyPress event?
« Reply #1 on: January 06, 2022, 01:19:39 pm »
Char only supports single Byte characters, thus larger Unicode characters can never be handled with OnKeyPress. You need to handle OnUTF8KeyPress instead.

loaded

  • Hero Member
  • *****
  • Posts: 825
Re: How to detect unicode characters in KeyPress event?
« Reply #2 on: January 06, 2022, 01:28:08 pm »
Thank you very much PascalDragonfor your reply.
Char only supports single Byte characters, thus larger Unicode characters can never be handled with OnKeyPress. You need to handle OnUTF8KeyPress instead.

It was very sad not to think about it.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

 

TinyPortal © 2005-2018