yes. im are not a advanced c++ programmer. howover this is a function that can been used as a workaround. im have only supported US keyboard for now. but other keyboard is very easy to been supported, if you read a keyboard.ini in your folder, so the keyboard layout can been changed that way. Im know this is not perfect, far away, but much better than nothing. what im should do is doing a system call to checking the visual scancode from Windows from the scancode. But im not sure how to do that.
its on purpose to hold the whole code into a the function. on some platforms, DIM static might require to been declared as GLOBAL...
But hey you have idea what im would do with this.
// a little workaround version of bugged INKEY$().
//
// Since im are not sure how TO detect the country keyboard layout (USA, German, France etc).
// Its best to read the layout from a inifile and put the result into those argument. example in this layout in the ini file:
//
//
// small=..1234567890....qwertyuiop....asdfghjkl.....zxcvbnm
// big=..1234567890....QWERTYUIOP....ASDFGHJKL.....ZXCVBNM
//
// you can also add extra keys and translate to chr values, example by using functions keys if you want. Something that is
// not possible with original INKEY$().
//
// Also this function might output more than one char, if two keys is pressed down same time on same frame.
FUNCTION INKEY2$: small$="..1234567890....qwertyuiop....asdfghjkl.....zxcvbnm", big$="..1234567890....QWERTYUIOP....ASDFGHJKL.....ZXCVBNM", skip$="."
STATIC i_scancodes[]
STATIC i_init=0
IF i_init=0
i_init=1
DIM i_scancodes[256]
ENDIF
LOCAL keys$=""
LOCAL keys[]
DIM keys[10]
LOCAL nr=-1
FOR i=1 TO 255
IF KEY(i)=1
i_scancodes[i]=i_scancodes[i]+1
ELSE
i_scancodes[i]=0
ENDIF
IF i_scancodes[i]=1 // here we could also eventuelly supports key repeat. but its up to you if you want.
nr=nr+1
IF nr<9
keys[nr]=i
ELSE
BREAK
ENDIF
ENDIF
NEXT
LOCAL ikey$=""
IF nr>-1
LOCAL letters$=small$
IF (KEY(42)=1 OR KEY(54)=1) AND big$<>"" THEN letters$=big$ // big letters, if required.
FOR i=0 TO 9
IF keys[i]>0
LOCAL ch$=MID$(letters$,keys[i],1)
IF ch$<>skip$ THEN ikey$=ikey$+ch$ // a letter
IF keys[i]=57 THEN ikey$=ikey$+" " // spacebar
IF keys[i]=28 THEN ikey$=ikey$+CHR$(13) // enter
IF keys[i]=14 THEN ikey$=ikey$+CHR$(8) // backspace
// you can expand it here with extra keys required, example F keys etc and use special letter to that.
ENDIF
NEXT
RETURN ikey$
ENDIF
RETURN ""
ENDFUNCTION
in a text adventure, you dont need to checking the full keyboard at all, and is property only in English anyway, but as im say the arguments in the function is designed so more keyboard layout easy can been added.
Please Note, INKEY$ here might return more than one letter, when two keys is pressed down on the same frame. The function is to been called every time by every SHOWSCREEN.