Added support for text input

I really should have looked at your pending pull requests before writing this, but if there's anything clever in here worth using, please feel free