Here is what I use for taking input without causing the program to wait for the return key to be pressed before continuing:
// Input
string Input(int iAction, bool bSpaceRemove)
{
static string sEntryText;
string sEntryTemp;
static int iDeleteT;
// Put entry data into entry string (allows for greater manipulation)
if(iAction == 1)
{
// Remove characters to prevent errors
int iCharFind;
// Backspace remove
do
{
iCharFind = sEntryText.rfind(dbChr(8));
if( iCharFind != string::npos) {sEntryText.erase(iCharFind);}
} while (iCharFind != string::npos);
// Tab remove
do
{
iCharFind = sEntryText.rfind(dbChr(9));
if( iCharFind != string::npos) {sEntryText.erase(iCharFind);}
} while (iCharFind != string::npos);
// Return/enter remove
do
{
iCharFind = sEntryText.rfind(dbChr(13));
if( iCharFind != string::npos) {sEntryText.erase(iCharFind);}
} while (iCharFind != string::npos);
// Escape remove
do
{
iCharFind = sEntryText.rfind(dbChr(27));
if( iCharFind != string::npos) {sEntryText.erase(iCharFind);}
} while (iCharFind != string::npos);
// Space remove
if (bSpaceRemove == true)
{
do
{
iCharFind = sEntryText.rfind(dbChr(32));
if( iCharFind != string::npos) {sEntryText.erase(iCharFind);}
} while (iCharFind != string::npos);
}
// Delete last letter if backspace key is pressed
if ( (dbKeyState(14) == 1) && (iDeleteT < (dbTimer()-500)) )
{
if (sEntryText.length() > 0)
{
int iLength = sEntryText.length();
sEntryText.resize(iLength-1);
sEntryTemp = sEntryText;
}
if (iDeleteT == 0) {iDeleteT = dbTimer();}
}
if( (dbKeyState(14) == 0) && (iDeleteT != 0) ){iDeleteT = 0;}
if (dbAsc(dbEntry()) != 0){sEntryText = sEntryText+dbEntry();} // fixes bug of crash when nothing in entry
sEntryTemp = sEntryText;
}
// Delete everything
if(iAction == 2)
{
sEntryTemp = sEntryText;
sEntryText.clear();
}
dbClearEntryBuffer();
return(sEntryTemp);
}
-Set iAction to 1 when you want to simply return currently entered text and accept backspaces.
-Set iAction to 2 when you want to delete everything currently stored.
-Set bSpaceRemove to true if you want spaces to be removed from input.
-Returned is currently entered text.
Hope this Helps!