InKey$
InKey$
Am I correct that this tool has not been clearly defined in the documentation? I don't have a clue as to how to use it, in programs. Nothing is shown as to its attributes either. Does someone know it well? May I have some clue as to its power? Thanks.
Re: InKey$
That sounds like a retro command. Look at Inkey() and its use:
String$ = Inkey()
String$ = Inkey()
Re: InKey$
Inkey() is a console function.
Code: Select all
OpenConsole()
Print("What is your name? ")
While (1) : Delay(1)
key.s = Inkey()
If RawKey() <> 13
If key <> ""
name.s + key
Print(key)
EndIf
Else
PrintN("")
Break
EndIf
Wend
If name.s <> ""
PrintN("Good to meet you, " + name.s)
EndIf
PrintN(#LF$ + "Press any key to quit...")
Input()
▓▓▓▓▓▒▒▒▒▒░░░░░
Re: InKey$
Should this work on OSX it doesnt seem to show anything I also tried
it also is not showing any key press. I have tried it in the IDE and also compiled.
I need program to just wait for a key press.
Thanks
Code: Select all
If OpenConsole ()
PrintN("Press Escape to exit")
Repeat
KeyPressed$ = Inkey()
If KeyPressed$ <> ""
PrintN("You pressed: " + KeyPressed$)
PrintN("It has a raw code of: "+Str(RawKey()))
ElseIf RawKey ()
PrintN("You pressed a non ASCII key.")
PrintN("It has a raw code of: "+Str(RawKey()))
Else
Delay(20) ; Don?t eat all the CPU time, we?re on a multitask OS
EndIf
Debug KeyPressed$
;Debug i
;i = i + 1
Until KeyPressed$ = Chr(27) ; Wait until escape is pressed
EndIf
I need program to just wait for a key press.
Thanks
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
Re: InKey$
@vwidmer
for using in the IDE set CompilerOption to console!
for using the executable, open a terminal
for using in the IDE set CompilerOption to console!
for using the executable, open a terminal
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: InKey$
If you double-click a console program, it opens a terminal and runs.ts-soft wrote:for using the executable, open a terminal
Re: InKey$
Sorry for not a clear question. I am not having a problem running it. I understand about using the console and terminal and compiling.
The problem I am having is that the keys are not being shown or captured. Unless I press a key a second after launching then it will recognize but if I wait a sec nothing seems to capture.
Thanks
The problem I am having is that the keys are not being shown or captured. Unless I press a key a second after launching then it will recognize but if I wait a sec nothing seems to capture.
Thanks
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
Re: InKey$
I tried it running in winXP and Linux and it seems to work fine just not on my OSX system any one else can try it on osx?
Thanks
Thanks
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA