Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

while Loop and Keyboard [9/11]

This program also displays whether a key is pressed or not.

Run the program and test it. Then, use the Escape key to end it.

After executing the program, modify it by using an if statement so that the program displays a text "A key is pressed" while any key is pressed.

Solution

Insert this statement in the middle of the loop: if isPressed(lastKeyName())
: println "A key is Pressed";

Loading...