Hello.
I just ran a similar problem with editbox 'OnUTF8KeyPress' event, while implementing number type check (tried to, did drive me mad until changed the event to 'OnChange' where my logic did work as expected.) Going to sleep, took so long. I can post a sample code and version (older FPC/LCL) info tomorrow.
It seems at my case that there is key stack index error in form that returned key would be n-1 value, can be seen that if I do enter 0 it returns 'not integer', when I hit backspace and box is empty it returns 'is integer'

This in my old win7 machine.
Or am I just too sleep deprived.

Edit. ..or the edit.text and 'OnUTF8KeyPress' event is out of sync.
Edit on next day:LAZ 2.0.4 / FPC 3.0.4 / Win7UTF8KeyPress event the UTF8Key is on sync, but the edit.text value is out of sync in n-1 fashion, not updated to event.. I wonder if this is intentional, I see logic at both ways n and n-1 value on occasion of keypress event, which both can cause a headache depending of the situation.
Standard Laz. application from wiz, in unit1 implementation as follows
Function isStrInt(const inStr:String): boolean;
var nTest : int64;
begin
Try
isStrInt := True;
nTest := strToInt(inStr);
Except
on E:Exception do begin
isStrInt := False;
end;
end;
end;
procedure TForm1.Edit1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
begin
if IsStrInt(Edit1.Text) Then begin
edit3.text :='OK';
end
else begin
edit3.text :='not';
end;
if IsStrInt(UTF8Key) Then begin
edit4.text := 'OK'
end
else begin
edit4.Text:= 'not';
end;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
if IsStrInt(Edit1.Text) Then begin
edit2.text :='ok';
end
else begin
edit2.text :='not';
end;
end;