Reputation: 8043
I was trying to detect Ctrl+V from a TEdit
's OnKeyPress
event and I've noticed that the Key
parameter assumes an unusual value when pressing Ctrl+AnyKey.
Example:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
ShowMessage(IntToStr(Ord(Key)));
end;
It produces the following results:
I don't understand how keys are translated, what does these codes mean?
It seems it has nothing to do with the ASCII table:
Could anyone shed some light on this?
Upvotes: 3
Views: 3271
Reputation: 34899
I don't understand how keys are translated, what does these codes mean?
The values you get with the Ctrl+AnyKey combinations are Ascii control codes.
They emanate from the need to enter non-printing (control) characters from the keyboard. The (typical) values for the control characters are below 32 plus the del
character (127).
Some more information about the history behind and standards could be found here and here.
Upvotes: 6