# Grabbing keystrokes from keyboard

**URL:** https://xrp.discourse.group/t/grabbing-keystrokes-from-keyboard/839
**Category:** Python programming
**Created:** [August 12, 2025, 7:35pm UTC](https://xrp.discourse.group/t/grabbing-keystrokes-from-keyboard/839 "2025-08-12T19:35:35Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![FizzDude](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@FizzDude](https://xrp.discourse.group/u/FizzDude)
#### Post date: [August 12, 2025, 7:35pm UTC](https://xrp.discourse.group/t/grabbing-keystrokes-from-keyboard/839/1 "2025-08-12T19:35:35Z")

</div>

I am writing simple Python code to control an XRP robot using the xrpcode.wpi.edu web browser interface. I want to control movement of the robot with a simple “wasd” scheme of keystrokes - forward, turn left, backward, turn right. I can’t figure out how to capture the keystrokes; or rather, I can’t figure out how to import the keyboard library in a way that this environment requires. Any tips?

---

<div class="post-metadata">

### Author: ![Fgrossman](https://avatars.discourse-cdn.com/v4/letter/f/b77776/32.png) [@Fgrossman](https://xrp.discourse.group/u/Fgrossman)
#### Post date: [August 13, 2025, 1:49pm UTC](https://xrp.discourse.group/t/grabbing-keystrokes-from-keyboard/839/2 "2025-08-13T13:49:46Z")

</div>

A few tips:

1 - The new gamepad API supports wasd if you want to use that.  
2 - You can get the input directly in your program. When doing this you need to make sure that the Shell window in the XRPCode is the selected window so that your typed input is going to the micropython program.  
import sys  
sys.stdin.read(1)

3 - if you wanted a non-blocking keyboard input you can look up the micropython select object.

---

<div class="post-metadata">

### Author: ![oakvilledynamics8719](https://avatars.discourse-cdn.com/v4/letter/o/ecc23a/32.png) [@oakvilledynamics8719](https://xrp.discourse.group/u/oakvilledynamics8719)
#### Post date: [August 15, 2025, 9:46pm UTC](https://xrp.discourse.group/t/grabbing-keystrokes-from-keyboard/839/3 "2025-08-15T21:46:42Z")

</div>

`how do you use the new gamepad feature? I have tried to use it but no luck. `

---

<div class="post-metadata">

### Author: ![Fgrossman](https://avatars.discourse-cdn.com/v4/letter/f/b77776/32.png) [@Fgrossman](https://xrp.discourse.group/u/Fgrossman)
#### Post date: [August 16, 2025, 12:01am UTC](https://xrp.discourse.group/t/grabbing-keystrokes-from-keyboard/839/4 "2025-08-16T00:01:05Z")

</div>

Currently it only works over Bluetooth. But if you have a use case for when it is connected via usb we would be interested.

---

<div class="post-metadata">

### Author: ![oakvilledynamics8719](https://avatars.discourse-cdn.com/v4/letter/o/ecc23a/32.png) [@oakvilledynamics8719](https://xrp.discourse.group/u/oakvilledynamics8719)
#### Post date: [August 16, 2025, 12:27am UTC](https://xrp.discourse.group/t/grabbing-keystrokes-from-keyboard/839/5 "2025-08-16T00:27:23Z")

</div>

I do have the xrp connected over Bluetooth. Does the game pad have to be connected via Bluetooth also?

---

<div class="post-metadata">

### Author: ![Fgrossman](https://avatars.discourse-cdn.com/v4/letter/f/b77776/32.png) [@Fgrossman](https://xrp.discourse.group/u/Fgrossman)
#### Post date: [August 16, 2025, 12:49am UTC](https://xrp.discourse.group/t/grabbing-keystrokes-from-keyboard/839/6 "2025-08-16T00:49:46Z")

</div>

Nope, the gamepad should be connected to the PC running XRPCode. When you push a button or move the joystick a gamepad icon should show on the top bar of XRPCode. There is a gamepad example program in the examples directory.

---

<div class="post-metadata">

### Author: ![oakvilledynamics8719](https://avatars.discourse-cdn.com/v4/letter/o/ecc23a/32.png) [@oakvilledynamics8719](https://xrp.discourse.group/u/oakvilledynamics8719)
#### Post date: [August 16, 2025, 1:01am UTC](https://xrp.discourse.group/t/grabbing-keystrokes-from-keyboard/839/7 "2025-08-16T01:01:31Z")

</div>

Thank you I got it to work thank you

---

<div class="post-metadata">

### Author: ![oakvilledynamics8719](https://avatars.discourse-cdn.com/v4/letter/o/ecc23a/32.png) [@oakvilledynamics8719](https://xrp.discourse.group/u/oakvilledynamics8719)
#### Post date: [August 16, 2025, 1:47am UTC](https://xrp.discourse.group/t/grabbing-keystrokes-from-keyboard/839/8 "2025-08-16T01:47:21Z")

</div>

Do you know where to find the example code?
