Recent

Author Topic: Ordinal Numbers  (Read 1615 times)

nugax

  • Full Member
  • ***
  • Posts: 232
Ordinal Numbers
« on: January 19, 2018, 09:15:54 pm »
how can I view the ordinal numbers of the keys? I know ESC is 27, but how can I parse them into a loop so I can see each key?
-Nugax

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Ordinal Numbers
« Reply #1 on: January 19, 2018, 09:21:03 pm »
open the unit lcltype and locate the constant vk_unknown. you will find all the key codes there. If you insist on finding for your self then create a new application and write a keydown event for the main form. the parameter key has the code you are looking for.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Ordinal Numbers
« Reply #2 on: January 19, 2018, 09:27:10 pm »
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.

Code: Pascal  [Select][+][-]
  1. program project1;
  2. uses Crt;
  3. var
  4.   Key: Char;
  5. begin
  6.   repeat
  7.     Key := ReadKey;
  8.     WriteLn('You pressed ', Ord(Key));
  9.   until key = #27;
  10. end.
« Last Edit: January 19, 2018, 09:29:57 pm by rvk »

nugax

  • Full Member
  • ***
  • Posts: 232
Re: Ordinal Numbers
« Reply #3 on: January 19, 2018, 10:10:04 pm »
Exactly what I needed! Thanks!
-Nugax

 

TinyPortal © 2005-2018