How Do i execute text

I Want to know how to when you press any key it shows it in a widget please give me an answer