# What is a simple way to pull input from a keyboard and attach it to a std::string?

The question says it all to be honest. I have a game that I am making in Ogre3D, using OIS as the main input library. My issue is that I am attempting to use CEGUI (with tons of errors) all to simply attempt making a string for my upcoming textbox class. The textbox graphics and font are already taken care of (by other classes), but what I need is the text from the keyboard to make this all happen (and this implementation seems way to difficult being such a commonplace thing to have in any program...).

My closest attempt with making a string to simulate that is as follows:

class CustomKeyListener: public OIS::KeyListener{
using namespace OIS;
public:
std::string mString;
CustomKeyListener(){mString="Blank";};
bool keyPressed(const KeyEvent &arg){
CEGUI::GUIContext& context = CEGUI::System::getSingleton().getDefaultGUIContext();
context.injectKeyDown((CEGUI::Key::Scan)arg.key);
context.injectChar((CEGUI::Key::Scan)arg.text);
std::cout<<arg.text<<std::endl;
return true;
}
bool keyReleased(const KeyEvent &arg){
CEGUI::System::getSingleton().getDefaultGUIContext().injectKeyUp((CEGUI::Key::Scan)arg.key);
return true;
}
};


As stated in the code, I want mString to be the containing text, and the textbox class (not made yet) will pull that string out and use it for whatever purposes. I would also like the idea of not having CEGUI included in the example if unneccesary (since it doesn't even take input, but gave me over a hundred errors upon adding to the program...)