Page 1 of 1

InKey$

Posted: Mon Jan 07, 2013 3:30 am
by ltrail
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$

Posted: Mon Jan 07, 2013 3:46 am
by Tenaja
That sounds like a retro command. Look at Inkey() and its use:
String$ = Inkey()

Re: InKey$

Posted: Mon Jan 07, 2013 4:34 am
by Nituvious
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$

Posted: Mon Jan 20, 2014 6:41 pm
by vwidmer
Should this work on OSX it doesnt seem to show anything I also tried

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
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

Re: InKey$

Posted: Mon Jan 20, 2014 7:24 pm
by ts-soft
@vwidmer

for using in the IDE set CompilerOption to console!
for using the executable, open a terminal

Re: InKey$

Posted: Mon Jan 20, 2014 7:57 pm
by Danilo
ts-soft wrote:for using the executable, open a terminal
If you double-click a console program, it opens a terminal and runs.

Re: InKey$

Posted: Mon Jan 20, 2014 8:34 pm
by vwidmer
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

Re: InKey$

Posted: Mon Jan 20, 2014 10:00 pm
by vwidmer
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