# Use a media keyboard with your pHat Beat, can it be done?

**URL:** <https://forums.pimoroni.com/t/use-a-media-keyboard-with-your-phat-beat-can-it-be-done/5176>\
**Category:** Support\
**Created:** [July 1, 2017, 12:53pm UTC](https://forums.pimoroni.com/t/use-a-media-keyboard-with-your-phat-beat-can-it-be-done/5176 "2017-07-01T12:53:12Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [July 3, 2017, 7:51pm UTC](https://forums.pimoroni.com/t/use-a-media-keyboard-with-your-phat-beat-can-it-be-done/5176/5 "2017-07-03T19:51:53Z")

</div>

> [@alphanumeric](#):
>
> unindent does not match any outer indentation level

I edited it to this and it now passes the check module function in idle3. Will run it on my Pi latter on tonight to see what happens.

import usb.core  
import usb.util  
import time

USB\_IF = 0 # Interface  
USB\_TIMEOUT = 5 # Timeout in MS

USB\_VENDOR = 0x1997 # Rii  
USB\_PRODUCT = 0x2433 # Mini Wireless Keyboard

dev = usb.core.find(idVendor=USB\_VENDOR, idProduct=USB\_PRODUCT)

endpoint = dev[0][(0,0)][0]

if dev.is\_kernel\_driver\_active(USB\_IF) is True:  
dev.detach\_kernel\_driver(USB\_IF)

usb.util.claim\_interface(dev, USB\_IF)

while True:  
control = None

try:  
control = dev.read(endpoint.bEndpointAddress, endpoint.wMaxPacketSize, USB\_TIMEOUT)  
print (control)  
except:  
pass

time.sleep(0.01) # Let CTRL+C actually exit

I can’t find the code tags?

---

_[View the full topic](https://forums.pimoroni.com/t/use-a-media-keyboard-with-your-phat-beat-can-it-be-done/5176)._
