-2

Suppose that x='hello'. My program then asks you for an input. I want it to move on to the next line as soon as you type hello. I'm not sure how to do this without pressing enter.

John
  • 11
  • 4
  • Something in [this](https://stackoverflow.com/questions/510357/python-read-a-single-character-from-the-user) answer could be useful – omeanwell Apr 02 '18 at 17:46

1 Answers1

0

Though I am not familiar with Python but here is how I would have done it in C#.

Step 1) I will add a OnKeyDown Event to the textbox in which the text is to be added.

Step 2) Every time a key is pressed, my OnKeyDown event will check whether the input matches the particular output or not, in you case, "hello".

Here is how the code will look like:-

private void OnKeyDown(object sender, EventArgs e)

{

 if(textbox.Text=="hello")
  textbox.Text+="\n";

}

I think the similar logic will work in Python. Try creating or using the similar Event Handler that I used in the code, ie OnKeyDown.

Mohsin Yaqoob
  • 68
  • 1
  • 8