Kodi Community Forum
Solved Multiple actions for keymap? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Skinning (https://forum.kodi.tv/forumdisplay.php?fid=12)
+--- Thread: Solved Multiple actions for keymap? (/showthread.php?tid=314405)



Multiple actions for keymap? - aegidius - 2017-05-15

Keymap question...

Is it possible to have multiple actions when a key is hit?
- such as Dialog.Close(VideoOSD); ActivateWindow(TVGuide)

Alternatively, is it possible for a key to send a press to a button on the screen?


Multiple actions for keymap? - cizzz - 2017-05-15

Yes. Just put all your actions in a .py script file and execute this script via a key-map definition.

E.g.:
In keymaps.xml

<key id="xxxxx">
runscript(special://masterprofile/addon_data/scripts/myactions.py)
</key>


In myactions.py:

     import xbmc

     xbmc.executebuiltin("Action(SubtitleDelayPlus)")
     xbmc.executebuiltin("Action(SubtitleDelayPlus)")
     xbmc.executebuiltin("Action(SubtitleDelayPlus)")
     xbmc.executebuiltin("Action(SubtitleDelayPlus)")
     xbmc.executebuiltin("Action(SubtitleDelayPlus)")


This script lets me delay my subtitles 1/2 a second (5 times 0.1 seconds)


RE: Multiple actions for keymap? - aegidius - 2017-05-15

Cool, thanks!


RE: Multiple actions for keymap? - wiak - 2021-06-03

(2017-05-15, 10:31)cizzz Wrote: Yes. Just put all your actions in a .py script file and execute this script via a key-map definition.

E.g.:
In keymaps.xml

<key id="xxxxx">
runscript(special://masterprofile/addon_data/scripts/my actions.py)
</key>


In actions.py:

import xbmc

xbmc.executebuiltin("Action(SubtitleDelayPlus)")
xbmc.executebuiltin("Action(SubtitleDelayPlus)")
xbmc.executebuiltin("Action(SubtitleDelayPlus)")
xbmc.executebuiltin("Action(SubtitleDelayPlus)")
xbmc.executebuiltin("Action(SubtitleDelayPlus)")

This script lets me delay my subtitles 1/2 a second (5 times .1 seconds)
i have a remote
by default the arrow keys behave like normal but when i play a video file, i want to be able to use arrow down and up for next and previous file, i probobly need a condition for when arrow keys should work i default mode and then switch to next/previous when playing a video


RE: Multiple actions for keymap? - cizzz - 2021-12-30

Late reply. :-)
Yes, you can install the Kodi keymap editor addon for that. This will allow you to remap your remote buttons as you wish depending on the Kodi section you are in.
Here is an example that I'm using when in video fullscreen.
E.g. When I press "0" on my remote, it activates the subtitle download window immediately when I'm playing a video.
 
Quote:
Code:
<keymap>
    <global>
        <keyboard>
            <key id="f5">xbmc.reloadskin()</key>
            <key id="f6">skin.togglesetting(debuggrid)</key>
            <key id="f7">skin.togglesetting(hidedebuginfo)</key>
            <key id="f8">notification(testing 123,hello world)</key>
            <key id="red">activatewindow(10040,"addons://user/all",return)</key>
            <key id="green">info</key>
            <key id="yellow">pageup</key>
            <key id="blue">pagedown</key>
            <key id="61668">activatewindow(settings)</key>
        </keyboard>
    </global>
    <music>
        <keyboard>
            <key id="61489">audiodelayminus</key>
            <key id="61491">audiodelayplus</key>
        </keyboard>
    </music>
    <videos>
        <keyboard>
            <key id="61628">contextmenu</key>
        </keyboard>
    </videos>
    <fullscreenvideo>
        <keyboard>
            <key id="61495">audiodelayminus</key>
            <key id="61497">audiodelayplus</key>
            <key id="61492">subtitledelayminus</key>
            <key id="61489">runscript(special://masterprofile/addon_data/scripts/subminus.py)</key>
            <key id="61627">runscript(special://masterprofile/addon_data/scripts/subminus.py)</key>
            <key id="61494">subtitledelayplus</key>
            <key id="61491">runscript(special://masterprofile/addon_data/scripts/subplus.py)</key>
            <key id="61626">runscript(special://masterprofile/addon_data/scripts/subplus.py)</key>
            <key id="61488">activatewindow(subtitlesearch)</key>
            <key id="61584">activatewindow(subtitlesearch)</key>
            <key id="61490">showsubtitles</key>
            <key id="61637">fastforward</key>
            <key id="61636">rewind</key>
            <key id="61496">audionextlanguage</key>
            <key id="61493">nextresolution</key>
            <key id="61493">info</key>
            <key id="61448">stop</key>
            <key id="61668">bigstepforward</key>
            <key id="61667">bigstepback</key>
        </keyboard>
    </fullscreenvideo>
</keymap>



RE: Multiple actions for keymap? - ontap - 2021-12-30

I find this confusing , the keymap text you show above , the brackets say "keyboard" , I naturally assumed that they were keyboard buttons mapped to control kodi , but you say the subtitle menu appears when you press "0" on your remote ?
Also , how would I identify key"0" looking at those codes in your list please ?


RE: Multiple actions for keymap? - cizzz - 2024-04-04

Correct. A remote control device is also considered a keyboard in Kodi.