My GetKey() won't work in text mode.

Archives Forums/BlitzPlus Bug Reports/My GetKey() won't work in text mode.

schilcote(Posted 2009) [#1]
When I use GetKey() and press a key, nothing happens.

This code continually prints 0s no matter what I do.

Repeat 
Print GetKey()
Forever


The blitz docs example code won't display anything either. I just updated Blitz, so it should work. My waitkey dosn't work either.

However, if I enable graphics mode, they both work. Why?

EDIT:
KeyDown() won't work either.


Matty(Posted 2009) [#2]
Try this:

repeat

a=getkey()
if a<>0 then print a

until keydown(1)<>0
end


Sauer(Posted 2009) [#3]
The console doesn't respond to key presses, except enter when the input command is called.

Use graphics mode for GetKey().


KillerX(Posted 2009) [#4]
It's because there's nothing to slow it down. The GetKey() displays something, but it isn't on the screen for long enough to be rendered by the monitor. Through in a "delay 100" and you'll be able to see it.


ozzi789(Posted 2009) [#5]
As far as i know, GetKey wont work in the Console
If you have a Graphis/CreateWindow it will work

Graphics 300, 300, 32, 2
SetBuffer BackBuffer()

Repeat
localChar = GetKey()
If localChar > 0 Then
currentText$ = Chr$(localChar)
ascii = localChar
EndIf
Text 0, 0, "ASCII Code: " + ascii
Text 0, 10, "LETTER: " + currentText$
Flip
Cls
Until KeyDown(1)
End