The code below has the following problem.
-After backspace has been pressed (char code of 14): if 'key' is in the entry buffer, "Key has been typed
" will be printed. This is what should happen.
-After return (enter) key has been pressed but before the backspace key has been pressed "Key has been typed
" is NOT printed if 'key' is in the buffer. This should not happen. "Key has been typed
" should be printed regardless, if 'key' is in the buffer.
Have I made a mistake in the code below?
#include "darkgdk.h"
#include "string"
using namespace std;
string Stemp;
char Ctemp[128];
void DarkGDK(void)
{
while (LoopGDK ())
{
if (dbReturnKey() == 1) // if return key is pressed
{
Stemp = dbEntry();
if (Stemp == "key")
{
dbPrint("Key has been typed :)");
}
else
{
dbPrint(dbEntry());
}
dbClearEntryBuffer(); // clear buffer
while (dbReturnKey() == 1) {} // wait for return key to be lifted
}
if (dbScanCode() == 14) // if backspace is pressed
{
dbClearEntryBuffer();
}
if (dbEscapeKey() == 1) {return;}
dbWait(1);
}
}