{{fbdoc item="title" value="INKEY"}}----
Returns a string representing the first key waiting in the keyboard buffer

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Inkey** ( ) [[KeyPgAs as]] [[KeyPgString string]]
##
{{fbdoc item="usage"}}##
	//result// = **Inkey**[$]
##
{{fbdoc item="ret"}}
	The first character found in the keyboard buffer, or an empty string (##"####"##) if none found.

{{fbdoc item="desc"}}
	Peeks into the keyboard buffer and returns a ##[[KeyPgString String]]## representation of the first character, if any, found. The key is then removed from the buffer, and is not echoed to the screen. If the keyboard buffer is empty, an empty string (##"####"##) is immediately returned without waiting for keys.

	If the key is in the ASCII character set, a one-character ##[[KeyPgString String]]## consisting of that character is returned. If the key is an "extended" one (numeric pad, cursors, functions) a two-character ##[[KeyPgString String]]## is returned, the first of which is the extended character  (//See dialect differences below//)

	The ""Shift"", ""Ctrl"", ""Alt"", and ""AltGr"" keys can't be read independently by this function as they never enter the keyboard buffer (although, perhaps obviously, Shift-A will be reported by ##**Inkey**## differently than Control-A et cetera; Alt-A is an extended key a la the above).
	
	See also ##[[KeyPgInputnum Input()]]## or ##[[KeyPgGetkey Getkey]]##, or ##[[KeyPgSleep Sleep]]## to wait for a key press if the keyboard buffer is empty.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/input/inkey.bas"}}%%(freebasic)
print "press q to quit"
do
	sleep 1, 1
loop until inkey = "q"
%%
{{fbdoc item="filename" value="examples/manual/input/inkeyext.bas"}}%%(freebasic)
#if __FB_LANG__ = "qb"
#define EXTCHAR Chr$(0)
#else
#define EXTCHAR Chr(255)
#endif

Dim k As String

Print "Press a key, or Escape to end"
Do

	k = Inkey$

	Select Case k

	    Case "A" To "Z", "a" To "z": Print "Letter: " & k
	    Case "1" To "9":             Print "Number: " & k

	    Case Chr$(32): Print "Space"

	    Case Chr$(27): Print "Escape"

	    Case Chr$(9): Print "Tab"

	    Case Chr$(8): Print "Backspace"

	    Case Chr$(32) To Chr$(127)
	        Print "Printable character: " & k

	    Case EXTCHAR & "G": Print "Up Left / Home"
	    Case EXTCHAR & "H": Print "Up"
	    Case EXTCHAR & "I": Print "Up Right / PgUp"

	    Case EXTCHAR & "K": Print "Left"
	    Case EXTCHAR & "L": Print "Center"
	    Case EXTCHAR & "M": Print "Right"

	    Case EXTCHAR & "O": Print "Down Left / End"
	    Case EXTCHAR & "P": Print "Down"
	    Case EXTCHAR & "Q": Print "Down Right / PgDn"

	    Case EXTCHAR & "R": Print "Insert"
	    Case EXTCHAR & "S": Print "Delete"


	    Case EXTCHAR & "k": Print "Close window / Alt-F4"

	    Case EXTCHAR & Chr$(59) To EXTCHAR & Chr$(68)
	        Print "Function key: F" & Asc(k, 2) - 58

	    Case EXTCHAR & Chr$(133) To EXTCHAR & Chr$(134)
	        Print "Function key: F" & Asc(k, 2) - 122

	    Case Else
	        If Len(k) = 2 Then
	            Print Using "Extended character: chr$(###, ###)"; Asc(k, 1); Asc(k, 2)
	        ElseIf Len(k) = 1 Then
	            Print Using "Character chr$(###)"; Asc(k)
	        End If

	End Select

	If k = Chr$(27) Then Exit Do

	Sleep 1, 1

Loop
%%

{{fbdoc item="lang"}}
	- The extended character is ##[[KeyPgChr Chr]](255)## in the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang fblite]]// dialects.
		- In the //[[CompilerOptlang -lang qb]]// dialect, the extended character depends on how the keyword is written. If the QB form ##**Inkey$**## is used, the extended character is ##[[KeyPgChr Chr]](0)##.  If it is referenced as ##**""__Inkey""**##, the extended char is ##[[KeyPgChr Chr]](255)##.
		- In all other dialects, the extended char is always ##[[KeyPgChr Chr]](255)##.
	- The string type suffix ##$## is optional in the //[[CompilerOptlang -lang fblite]]// and //[[CompilerOptlang -lang fb]]// dialects, but required in the //[[CompilerOptlang -lang qb]]// dialect.

{{fbdoc item="diff"}}
	- None in the //[[CompilerOptlang -lang qb]]// dialect.
	- QBasic returned a ##[[KeyPgChr Chr]](0)## as the first character for an extended key, but ""FreeBASIC"" returns ##[[KeyPgChr Chr]](255)## as the first character in the //[[CompilerOptlang -lang fb]]// and //[[CompilerOptlang -lang fblite]]// dialects.

{{fbdoc item="see"}}
	- ##[[KeyPgSleep Sleep]]##
	- ##[[KeyPgGetkey Getkey]]##
	- ##[[KeyPgInputnum Input()]]##
	- ##[[KeyPgMultikey Multikey]]##

{{fbdoc item="back" value="CatPgInput|User Input"}}