# Managing keys pressed by user

Most, if not all, plugins use at least some form of user input - waiting for the user, detecting a specific key, or checking if a key is pressed during runtime. Here, I'll show you how to do that.

### Waiting for the user's input

To wait for the user's input, you'd simply just call `tpil.waitForKey().` This returns the key the user pressed as a string (returns `left` for left, `press` for joystick press, `1` for key 1, ...)

{% hint style="info" %}
Want to wait for the user's input, but with a timeout?&#x20;

Use `tpil.waitWhileChkKey(timeout)` instead.
{% endhint %}

### Checking if the user is pressing a button

To check if the user is pressing a key, you can use `tpil.getKey().` This can be useful for when you're in a loop and if the user wants to get out of it, or to check if the user is holding down another key while also checking for another. This returns the same as `.waitForKey()`, and returns the string of the key pressed.







