Keyboard and mouse functions not working

BlitzPlus Forums/BlitzPlus Beginners Area/Keyboard and mouse functions not working

Cecrops(Posted 2014) [#1]
I just started using BlitzPlus, so I am trying some simple things. I am finding that the keyboard and mouse input functions are not working. These are the functions like WaitKey and WaitMouse. The examples for the documentation do not work. I am running Windows 8, if that means anything. Any help?


xlsior(Posted 2014) [#2]
Does the computer you're using have a touchscreen, by any chance?


RemiD(Posted 2014) [#3]
Edit :
This works on my computer even if i hold the key.
Graphics(800,600,32,2)

Print("Press any key to continue")
WaitKey()

Print("Line1")
WaitKey()

Print("Line2")
WaitKey()

End()


What you can do is try to use Flushkeys or FlushMouse to make sure that a WaitKey or a WaitMouse is not skipped :
Flushkeys()
Waitkey()
or
FlushMouse()
WaitMouse()


thehawk2323(Posted 2014) [#4]
I never use Flush~ or Wait~ functions ever. It works fine if you just keep checking for an event in a repeat/while loop.


Cecrops(Posted 2014) [#5]
xlsior - no touchscreen.

RemiD - Flushkeys function had no effect.

thehawk2323 - the Waitkeys function is supposed to stop the program execution at that statement until a key is pressed. No need for any loop.

I thought of another consideration. The example in the documentation for Waitkey is using the graphics mode. I have been running in the console. Does anyone know if maybe Waitkey only works in graphics and not console?

Thanks for the suggestions.


xlsior(Posted 2014) [#6]
The example in the documentation for Waitkey is using the graphics mode. I have been running in the console. Does anyone know if maybe Waitkey only works in graphics and not console?


It does indeed.

IIRC the same applies to keydown and keyhit, which does limit what you can do in console mode.

You do have the 'input' command, but it will wait for an entire string until you hit 'enter'

Not sure of a way around that, other than interfacing with the windows API directly and monitoring windows' GetAsyncKeyState functionality.


Cecrops(Posted 2014) [#7]
It would be nice if the documentation would tell which functions do not work in console mode. I was just afraid that for some strange reason many of the I/O functions were not going to work on my computer at all, and I was going to have to look for another language. I guess I will have to learn to do debugging in graphics mode.

Thanks for the help.


xlsior(Posted 2014) [#8]
Note that even in Graphics mode, you can still use the 'print' statement -- the results will end up in the IDE's output window.


Cecrops(Posted 2014) [#9]
Nice to know. What about the 'Input' statement? What I am planning is a turn-based strategy game that is mostly text, but the human player uses graphics to create maps for his own reference.