detect button press and use it in a Python script?
#16
@3000  You have got enough answers so far. As for you issues with inputs library, they have nothing to do with Kodi and you should address them to inputs developers.
Reply
#17
I don't want to use an external library and frankly, I still don't think I even have to.

So if anyone has another suggestion please let me know.

Otherwise I'll leave the tread as it is.
Reply
#18
I know this is kinda late, but maybe you can use the "onAction" callback:
Kodi Development page

Example:
python:
def onAction(self, action):
    log('Received Action: ' + str(action.getId()) + '\n', xbmc.LOGDEBUG)
    if action in (ACTION_PREVIOUS_MENU, ACTION_BACKSPACE, ACTION_NAV_BACK):
        # Do "Back" action
    if action in (ACTION_ENTER_KEY, ACTION_ENTER):
        # Do "Enter" action
Reply
#19
(2021-05-19, 13:00)AvanOsch Wrote: I know this is kinda late, but maybe you can use the "onAction" callback:
Kodi Development page

Example:
python:
def onAction(self, action):
    log('Received Action: ' + str(action.getId()) + '\n', xbmc.LOGDEBUG)
    if action in (ACTION_PREVIOUS_MENU, ACTION_BACKSPACE, ACTION_NAV_BACK):
        # Do "Back" action
    if action in (ACTION_ENTER_KEY, ACTION_ENTER):
        # Do "Enter" action

thank you. Appreciate the help! It's been some time since I was on it, will try your solution in the coming days. Let's hope it's gonna work Smile
Reply
#20
ok tried it. Didn't work.
Reply
#21
(2021-05-19, 13:00)AvanOsch Wrote: I know this is kinda late, but maybe you can use the "onAction" callback:
Kodi Development page

Example:
python:
def onAction(self, action):
    log('Received Action: ' + str(action.getId()) + '\n', xbmc.LOGDEBUG)
    if action in (ACTION_PREVIOUS_MENU, ACTION_BACKSPACE, ACTION_NAV_BACK):
        # Do "Back" action
    if action in (ACTION_ENTER_KEY, ACTION_ENTER):
        # Do "Enter" action
It doesn't work in such way, but info is very useful. To capture keypress at onAction callback one should:
1. Find id number for appropriate getId from here
2. Edit onAction for something like
python:
def onAction(self,action):
# capture idNumber found from above
if action.getId == idNumber:
# do whatever You need for given keypress
else:
# do something else
Reply

Logout Mark Read Team Forum Stats Members Help
detect button press and use it in a Python script?0