detect button press and use it in a Python script?
hi guys, I need help. How do I detect a button press (of my Xbox Controller) in Python?

I need to use it as part of an if-condition. Basically this:

"if button b is pressed then ..."

Any ideas?
Thanks guys!
you could map a key to run a script
I have already mapped my buttons. In this case it' not an option though.

I actually need the Python code which detects a button press. 

Like I described above I need it as an if-condition.

What does the Python code look like for: "if button b is pressed"?
You could create a service addon that listens to all the incoming notifications and does something if the notification is about a key press (and specifically the correct key press).

Here's a little bit about service addons:

And specifically the onNotification hook:

I don't remember off hand what notification event you need to listen for, so you might need to just create the service addon and have it log the messages to see if you can figure out which one will correspond to a keypress.

One last option. I've never used it, but there is an addon called Kodi Callbacks that might let you configure an event using a keypress as a trigger.
thank you! I need more help though. I tried the Kodi Callback add-on. (I knew it before and used it for other stuff.) It's not of any use for regarding pressing buttons.

I am still pretty much clueless what to do.
perhaps you can use the python inputs library:
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Thank you @ronie and @pkscout 

I created a service add-on and used python inputs library. Finally it's working.

Appreciate your help!!

Logout Mark Read Team Forum Stats Members Help
detect button press and use it in a Python script?0
This forum uses Lukasz Tkacz MyBB addons.