Board index » delphi » Readkey's

Readkey's

Hi,

I'm having trouble reading functionkey's in my program. I know a functionkey
has two ASCII values, the{*word*128}is #0, I've looked up this answer but that
does not seem to work with borland pascal for windows.

var
  a : char;
begin
  a := readkey;
  if a = #0 then
  begin
    write('Extended keycode! ');
    a := readkey;
  end;
  writeln('ASCII value of key: ',ord(a))
end.

I tought of putting it to a simple test:

REPEAT UNTIL keypressed;

The program wil not continue if I press a functionkey, with other keys it
just ends, what is the problem?? can anyone help me??

greetings Andrew.

 

Re:Readkey's


On Wed, 17 Oct 2001 20:07:16 +0200, "Andre Haverdings"

Quote
<AHaverdi...@soneramail.nl> wrote:

Try this. Modifications are all CAPS.
Quote
>Hi,

>I'm having trouble reading functionkey's in my program. I know a functionkey
>has two ASCII values, the{*word*128}is #0, I've looked up this answer but that
>does not seem to work with borland pascal for windows.

>var
>  a : char;
>begin
REPEAT
>  a := readkey;
>  if a = #0 then
>  begin
>    write('Extended keycode! ');
>    a := readkey;

   end  {SEMICOLON REMOVED}
   ELSE WRITE('NORMAL KEY: '
Quote
>  writeln('ASCII value of key: ',ord(a))

UNTIL ORD(a) = 27; {ESCAPE}

Quote
>end.

>I tought of putting it to a simple test:

>REPEAT UNTIL keypressed;

>The program wil not continue if I press a functionkey, with other keys it
>just ends, what is the problem?? can anyone help me??

>greetings Andrew.

{Try this}

var
  a : char;
begin
Repeat
  a := readkey;
  if a = #0 then
  begin
    write('Extended keycode! ');
    a := readkey;
  end
  ELSE WRITE('Standard Key: ');
  writeln('ASCII value of key: ',ord(a))
Until ord(a) = 27;  {Escape}
end.

Re:Readkey's


Hi,

I'm sorry it stil does not work, it seem as if readkey does not recognize a
function key as an key. what I try the halts on readkey unless I press a
regular key, it could be and other function that i'm not aware of that does
recognize functionkeys, I dont know.

Thanx anyway

gr

Quote
"Clif Penn" <clifp...@airmail.net> wrote in message

news:1EEFBE3960AAE0F6.97DA3F4E1710AAE3.3DFDB00697C9A535@lp.airnews.net...
Quote
> On Wed, 17 Oct 2001 20:07:16 +0200, "Andre Haverdings"
> <AHaverdi...@soneramail.nl> wrote:

> Try this. Modifications are all CAPS.
> >Hi,

> >I'm having trouble reading functionkey's in my program. I know a
functionkey
> >has two ASCII values, the{*word*128}is #0, I've looked up this answer but that
> >does not seem to work with borland pascal for windows.

> >var
> >  a : char;
> >begin
> REPEAT
> >  a := readkey;
> >  if a = #0 then
> >  begin
> >    write('Extended keycode! ');
> >    a := readkey;
>    end  {SEMICOLON REMOVED}
>    ELSE WRITE('NORMAL KEY: '
> >  writeln('ASCII value of key: ',ord(a))
> UNTIL ORD(a) = 27; {ESCAPE}
> >end.

> >I tought of putting it to a simple test:

> >REPEAT UNTIL keypressed;

> >The program wil not continue if I press a functionkey, with other keys it
> >just ends, what is the problem?? can anyone help me??

> >greetings Andrew.

> {Try this}

> var
>   a : char;
> begin
> Repeat
>   a := readkey;
>   if a = #0 then
>   begin
>     write('Extended keycode! ');
>     a := readkey;
>   end
>   ELSE WRITE('Standard Key: ');
>   writeln('ASCII value of key: ',ord(a))
> Until ord(a) = 27;  {Escape}
> end.

Re:Readkey's


Since windows is message (event) based and readkey is some polling
method you should consider to cathc these windows messages which include
the pressed keys. Ask someone else for "how to do this" as I don't know
much about Windooze stuff...

Markus

Re:Readkey's


Quote
>Since windows is message (event) based and readkey is some polling
>method you should consider to cathc these windows messages which include
>the pressed keys. Ask someone else for "how to do this" as I don't know
>much about Windooze stuff...

>Markus

I used to use TPW 1.5 and I think windows interprets the keys and assigns them
non-ascii values. The codes you need might be in your 'Windows' unit. I'm just
going by memory, maybe I'm thinking of a C compiler...

James

Other Threads