[SDL] Reading text from keyboard

Matt Monson madprog at hotmail.com
Fri Jan 17 23:03:01 PST 2003

dang, man, you're making this waaaay more hard than it has to be... this is 
what i use....

if(event.type is KEYDOWN)
if(event.key.keysym.sym == SDLK_BACKSPACE)
    // take the last letter off, if there are any letters
else if(event.key.keysym.sym == SDLK_RETURN)
    // process it, send it, whatever
	// i'm using c type strings (char vectors) so my code is kinda complex
	if(strlen(saying) < MAX_LEN)
		saying[strlen(saying)] = (char)event.key.keysym.unicode;

	// it looks like you could just do
	m_strText += (char)event.key.keysym.unicode;

STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 

More information about the SDL mailing list