Or if you use FPC only (console) (I saw in the other topic you used Linux FP console)
Notice that some keys (like the arrowkeys) are actually two keys. First #0 and second a positive number.
So if you are going to read those keys you need to take the special #0 value into consideration and read the second key and act upon it.
program project1;
uses Crt;
var
Key: Char;
begin
repeat
Key := ReadKey;
WriteLn('You pressed ', Ord(Key));
until key = #27;
end.