Skip to main content

Which key is pressed

  • March 1, 2012
  • 3 replies
  • 0 views

[Migrated content. Thread originally posted on 01 March 2012]

Hi all :-)

I would like a user to have the possibility to "break out" of a program execution by pressing the Escape key. I have the following code to determine if the user pressed the Escape key during the run:

ACCEPT KBD-INPUT-STATUS FROM INPUT STATUS.

IF KBD-INPUT-STATUS = ZERO
EXIT PARAGRAPH.

ACCEPT OMITTED
BEFORE TIME 0
WITH NO ADVANCING
ON EXCEPTION
ACCEPT KBD-HIT-KEY FROM ESCAPE.

Unfortunately the code halts if the user presses the space key.
Anyone have a better idea hos to dertermine if the user pressed the Escape key without having to hold the execution until a key is pressed ?

Thanks in advance.
Steen

3 replies

Stephen Hjerpe
  • Participating Frequently
  • 1100 replies
  • March 1, 2012

[Migrated content. Thread originally posted on 01 March 2012]

Hi all :-)

I would like a user to have the possibility to "break out" of a program execution by pressing the Escape key. I have the following code to determine if the user pressed the Escape key during the run:

ACCEPT KBD-INPUT-STATUS FROM INPUT STATUS.

IF KBD-INPUT-STATUS = ZERO
EXIT PARAGRAPH.

ACCEPT OMITTED
BEFORE TIME 0
WITH NO ADVANCING
ON EXCEPTION
ACCEPT KBD-HIT-KEY FROM ESCAPE.

Unfortunately the code halts if the user presses the space key.
Anyone have a better idea hos to dertermine if the user pressed the Escape key without having to hold the execution until a key is pressed ?

Thanks in advance.
Steen
Have you tried

ACCEPT OMITTED
BEFORE TIME 0
WITH NO ADVANCING
ON ESCAPE

  • Author
  • Rocketeer
  • 19312 replies
  • March 2, 2012

[Migrated content. Thread originally posted on 01 March 2012]

Hi all :-)

I would like a user to have the possibility to "break out" of a program execution by pressing the Escape key. I have the following code to determine if the user pressed the Escape key during the run:

ACCEPT KBD-INPUT-STATUS FROM INPUT STATUS.

IF KBD-INPUT-STATUS = ZERO
EXIT PARAGRAPH.

ACCEPT OMITTED
BEFORE TIME 0
WITH NO ADVANCING
ON EXCEPTION
ACCEPT KBD-HIT-KEY FROM ESCAPE.

Unfortunately the code halts if the user presses the space key.
Anyone have a better idea hos to dertermine if the user pressed the Escape key without having to hold the execution until a key is pressed ?

Thanks in advance.
Steen
Yes - that dosnt work.
For some reason the code after ON ESCAPE is executed even if I dont press any key ....?

  • Author
  • Rocketeer
  • 19312 replies
  • March 2, 2012

[Migrated content. Thread originally posted on 01 March 2012]

Hi all :-)

I would like a user to have the possibility to "break out" of a program execution by pressing the Escape key. I have the following code to determine if the user pressed the Escape key during the run:

ACCEPT KBD-INPUT-STATUS FROM INPUT STATUS.

IF KBD-INPUT-STATUS = ZERO
EXIT PARAGRAPH.

ACCEPT OMITTED
BEFORE TIME 0
WITH NO ADVANCING
ON EXCEPTION
ACCEPT KBD-HIT-KEY FROM ESCAPE.

Unfortunately the code halts if the user presses the space key.
Anyone have a better idea hos to dertermine if the user pressed the Escape key without having to hold the execution until a key is pressed ?

Thanks in advance.
Steen
Yes - that dosnt work.
For some reason the code after ON ESCAPE is executed even if I dont press any key ....?