Computer Science Canada Input.KeyDown (chars) not working |
Author: | Aerii [ Fri Apr 10, 2015 3:59 pm ] | ||||||||
Post subject: | Input.KeyDown (chars) not working | ||||||||
What is it you are trying to achieve? I'm trying to make it so when Enter is pressed it will start the code inside (Which is pretty much the program) What is the problem you are having? When I do:
It just goes straight to the else section of the code and skips everything else. So if I press enter or not then nothing happens. Describe what you have tried to solve this problem I've tried looking it up on here and using getch but none of that works. EDIT: FOUND THIS OUT!
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using Version 4.11 or something EDIT: I've figured out I will just use KEY_ESC for exiting the program. It works well and I don't need it to be any key but enter. |
Author: | DemonWasp [ Sat Apr 11, 2015 8:07 am ] |
Post subject: | RE:Input.KeyDown (chars) not working |
Input.KeyDown is almost certainly working correctly. Your loop, however, doesn't: it will only ever call Input.KeyDown one time. If you aren't holding down the Enter key at that time, then it will go into the 'else' clause and stay there for the next several seconds before quitting. If you wanted to make an "interactive" timer that waits 5 seconds for you to press Enter, then you need to look for the "game loop" posts on this site. Those will tell you how to poll for user input while also updating things on the screen (like "Exiting program in N seconds...") |