Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-09

readkey return

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jaakko Tamminen

Hi

For some reason I get the same code for shift-s (uppercase s) and DEL-key when I do following:

var ch : char;
...
repeat until keypressed;
ch := readkey;
case ch of
#83 : del_cur_ch;  {<-- this happens with upcase-S and DEL key ?}

Is there another way to read a pressed key, so that I could see the difference between upcase-S and DEL-key?

I'm programming in Linux ascii-console, and using FPC 1.0.4

Jaska.

Reply by email

Lee, John

the way to do it, see documentation for fpc ...eg

Example
Program Example3;
uses Crt;

{ Program to demonstrate the ReadKey function. }

var
  ch : char;
begin
  writeln('Press Left/Right, Esc=Quit');
  repeat
    ch:=ReadKey;
    case ch of
     #0 : begin
            ch:=ReadKey; {Read ScanCode}
            case ch of
             #75 : WriteLn('Left');
             #77 : WriteLn('Right');
	    end;
	  end;
    #27 : WriteLn('ESC');
    end;
  until ch=#27 {Esc}
end.

hth

Earlier message 30 lines
-----Original Message----- From: Jaakko Tamminen Sent: Monday, September 24, 2001 06:10 To: Free Pascal Subject: [fpc-pascal]readkey return Hi For some reason I get the same code for shift-s (uppercase s) and DEL-key when I do following: var ch : char; ... repeat until keypressed; ch := readkey; case ch of #83 : del_cur_ch; {<-- this happens with upcase-S and DEL key ?} Is there another way to read a pressed key, so that I could see the difference between upcase-S and DEL-key? I'm programming in Linux ascii-console, and using FPC 1.0.4 Jaska.

Reply by email

Unknown author
to Jaakko Tamminen: Hi For some reason I get the same code for shift-s (uppercase s) and DEL-key when I do…

Jaakko Tamminen sanoi:

Show quoted text 19 lines
Hi For some reason I get the same code for shift-s (uppercase s) and DEL-key when I do following: var ch : char; ... repeat until keypressed; ch := readkey; case ch of #83 : del_cur_ch; {<-- this happens with upcase-S and DEL key ?} Is there another way to read a pressed key, so that I could see the difference between upcase-S and DEL-key? I'm programming in Linux ascii-console, and using FPC 1.0.4
Bweep bweep. Try
ch := readkey;
if ch = #0 then ch := readkey;

This is because some of the more special keys are prefixed by #0 or even more key codes.

________________________________________________________________ Ilmainen Internet @ http://www.nic.fi/

Reply by email

Jaakko Tamminen
to Lee, John: the way to do it, see documentation for fpc ...eg Example Program Example3; uses Crt; {…

Thank You for this info.

Now it works, except END-key.. it seems to give 3 (!) codes... but I can live without that key... :-)

Jaska.

John wrote 73 lines
the way to do it, see documentation for fpc ...eg Example Program Example3; uses Crt; { Program to demonstrate the ReadKey function. } var ch : char; begin writeln('Press Left/Right, Esc=Quit'); repeat ch:=ReadKey; case ch of #0 : begin ch:=ReadKey; {Read ScanCode} case ch of #75 : WriteLn('Left'); #77 : WriteLn('Right'); end; end; #27 : WriteLn('ESC'); end; until ch=#27 {Esc} end. hth -----Original Message----- From: Jaakko Tamminen Sent: Monday, September 24, 2001 06:10 To: Free Pascal Subject: [fpc-pascal]readkey return Hi For some reason I get the same code for shift-s (uppercase s) and DEL-key when I do following: var ch : char; ... repeat until keypressed; ch := readkey; case ch of #83 : del_cur_ch; {<-- this happens with upcase-S and DEL key ?} Is there another way to read a pressed key, so that I could see the difference between upcase-S and DEL-key? I'm programming in Linux ascii-console, and using FPC 1.0.4 Jaska. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Arne Hanssen
to Lee, John: the way to do it, see documentation for fpc ...eg Example Program Example3; uses Crt; {…

Thus spoke Lee, John ():

Show quoted text 20 lines
{ Program to demonstrate the ReadKey function. } var ch : char; begin writeln('Press Left/Right, Esc=Quit'); repeat ch:=ReadKey; case ch of #0 : begin ch:=ReadKey; {Read ScanCode} case ch of #75 : WriteLn('Left'); #77 : WriteLn('Right'); end; end; #27 : WriteLn('ESC'); end; until ch=#27 {Esc} end.

You might want to escape #224 also as this code prefixes some special keys (to keep numpad-Home and Home apart or something like that as I remember it - the PC keyboard is somewhat messy!).

Vennlig hilsen / Best regards |\ ___,,--, _ Arne Hanssen, Senja, Norway /,`--'' \-,,__,'/ http://home.c2i.net/nite |,4 ) )_ ) /~-----' http://home.c2i.net/bkgras -----'---^~(_/-_)--(_/_)-------

Reply by email