I am trying to restrict key press of some special characters in the input box for my requirement and I am using the below procedure to do the same.
procedure RestrictKeyPress(Sender: TObject; var Key: Char);
var
KeyCode: Integer;
begin
{ Restrict special characters @, ^, *, \ }
KeyCode := Ord(Key);
if ((KeyCode = 32) or (KeyCode >= 64) or (KeyCode <= 94) or (KeyCode <= 42) or (KeyCode <= 92)) then
Key := #0;
end;
I am calling this procedure in the InitializeWizard like this
PageConfig.Edits[1].OnKeyPress := @RestrictKeyPress;
But when I test this, key press is not working for any keys. I am trying to restrict only the keys mentioned below and space.
@, ^, *, \