Create a schortcut for Keyboard Key + Scroll

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















I want to map the action ctrl+shift+tab + scroll to volume up/down. How can I achieve this?



I know that ctrl + scroll maps to zoom in/out by default. Surely, there must be a way to create such a custom shortcut no?



(I am running kde plasma 5.14.5)










share|improve this question


























    0















    I want to map the action ctrl+shift+tab + scroll to volume up/down. How can I achieve this?



    I know that ctrl + scroll maps to zoom in/out by default. Surely, there must be a way to create such a custom shortcut no?



    (I am running kde plasma 5.14.5)










    share|improve this question
























      0












      0








      0








      I want to map the action ctrl+shift+tab + scroll to volume up/down. How can I achieve this?



      I know that ctrl + scroll maps to zoom in/out by default. Surely, there must be a way to create such a custom shortcut no?



      (I am running kde plasma 5.14.5)










      share|improve this question














      I want to map the action ctrl+shift+tab + scroll to volume up/down. How can I achieve this?



      I know that ctrl + scroll maps to zoom in/out by default. Surely, there must be a way to create such a custom shortcut no?



      (I am running kde plasma 5.14.5)







      keyboard-shortcuts






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 27 at 11:02









      Dev AggarwalDev Aggarwal

      1012




      1012




















          1 Answer
          1






          active

          oldest

          votes


















          1














          As far as my reseach went, I wasn't able to find any elegant solution to the problem. I hacked a very crude python script that does the job poorly... I'm sorry.



          from pynput import keyboard
          from pynput import mouse
          from pynput.keyboard import Controller
          import subprocess
          from subprocess import call

          kbd = Controller()

          COMBINATIONS = [keyboard.Key.ctrl, keyboard.Key.shift]

          current = set()

          def execute():
          with mouse.Listener(on_scroll=on_mscroll) as listener:
          listener.join()

          def on_press(key):
          if any([key in COMBO for COMBO in COMBINATIONS]):
          current.add(key)
          if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS):
          # this executes only once and then it looses the keycombination
          execute()

          def on_release(key):
          if any([key in COMBO for COMBO in COMBINATIONS]):
          try:
          current.remove(key)
          except KeyError:
          pass

          def on_mscroll(x, y, dx, dy):
          if dy < 0:
          # this can be changed to the appropriate command to change the volume
          # like pactl
          call(["amixer", "-D", "pulse", "sset", "Master", "5%-"],stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
          else:
          call(["amixer", "-D", "pulse", "sset", "Master", "5%+"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
          return False

          with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
          listener.join()


          The problem with this is that you need to press ctrl + shift + scoll up/down and then RE-PRESS shift to toggle the action again. I mean it's annyong. Also this does not block the scroll, so you might want to scroll on a neutral place (like a sidebar).



          This uses pynput but I hope that won't be a problem






          share|improve this answer






















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503302%2fcreate-a-schortcut-for-keyboard-key-scroll%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            As far as my reseach went, I wasn't able to find any elegant solution to the problem. I hacked a very crude python script that does the job poorly... I'm sorry.



            from pynput import keyboard
            from pynput import mouse
            from pynput.keyboard import Controller
            import subprocess
            from subprocess import call

            kbd = Controller()

            COMBINATIONS = [keyboard.Key.ctrl, keyboard.Key.shift]

            current = set()

            def execute():
            with mouse.Listener(on_scroll=on_mscroll) as listener:
            listener.join()

            def on_press(key):
            if any([key in COMBO for COMBO in COMBINATIONS]):
            current.add(key)
            if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS):
            # this executes only once and then it looses the keycombination
            execute()

            def on_release(key):
            if any([key in COMBO for COMBO in COMBINATIONS]):
            try:
            current.remove(key)
            except KeyError:
            pass

            def on_mscroll(x, y, dx, dy):
            if dy < 0:
            # this can be changed to the appropriate command to change the volume
            # like pactl
            call(["amixer", "-D", "pulse", "sset", "Master", "5%-"],stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
            else:
            call(["amixer", "-D", "pulse", "sset", "Master", "5%+"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
            return False

            with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
            listener.join()


            The problem with this is that you need to press ctrl + shift + scoll up/down and then RE-PRESS shift to toggle the action again. I mean it's annyong. Also this does not block the scroll, so you might want to scroll on a neutral place (like a sidebar).



            This uses pynput but I hope that won't be a problem






            share|improve this answer



























              1














              As far as my reseach went, I wasn't able to find any elegant solution to the problem. I hacked a very crude python script that does the job poorly... I'm sorry.



              from pynput import keyboard
              from pynput import mouse
              from pynput.keyboard import Controller
              import subprocess
              from subprocess import call

              kbd = Controller()

              COMBINATIONS = [keyboard.Key.ctrl, keyboard.Key.shift]

              current = set()

              def execute():
              with mouse.Listener(on_scroll=on_mscroll) as listener:
              listener.join()

              def on_press(key):
              if any([key in COMBO for COMBO in COMBINATIONS]):
              current.add(key)
              if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS):
              # this executes only once and then it looses the keycombination
              execute()

              def on_release(key):
              if any([key in COMBO for COMBO in COMBINATIONS]):
              try:
              current.remove(key)
              except KeyError:
              pass

              def on_mscroll(x, y, dx, dy):
              if dy < 0:
              # this can be changed to the appropriate command to change the volume
              # like pactl
              call(["amixer", "-D", "pulse", "sset", "Master", "5%-"],stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
              else:
              call(["amixer", "-D", "pulse", "sset", "Master", "5%+"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
              return False

              with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
              listener.join()


              The problem with this is that you need to press ctrl + shift + scoll up/down and then RE-PRESS shift to toggle the action again. I mean it's annyong. Also this does not block the scroll, so you might want to scroll on a neutral place (like a sidebar).



              This uses pynput but I hope that won't be a problem






              share|improve this answer

























                1












                1








                1







                As far as my reseach went, I wasn't able to find any elegant solution to the problem. I hacked a very crude python script that does the job poorly... I'm sorry.



                from pynput import keyboard
                from pynput import mouse
                from pynput.keyboard import Controller
                import subprocess
                from subprocess import call

                kbd = Controller()

                COMBINATIONS = [keyboard.Key.ctrl, keyboard.Key.shift]

                current = set()

                def execute():
                with mouse.Listener(on_scroll=on_mscroll) as listener:
                listener.join()

                def on_press(key):
                if any([key in COMBO for COMBO in COMBINATIONS]):
                current.add(key)
                if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS):
                # this executes only once and then it looses the keycombination
                execute()

                def on_release(key):
                if any([key in COMBO for COMBO in COMBINATIONS]):
                try:
                current.remove(key)
                except KeyError:
                pass

                def on_mscroll(x, y, dx, dy):
                if dy < 0:
                # this can be changed to the appropriate command to change the volume
                # like pactl
                call(["amixer", "-D", "pulse", "sset", "Master", "5%-"],stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
                else:
                call(["amixer", "-D", "pulse", "sset", "Master", "5%+"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
                return False

                with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
                listener.join()


                The problem with this is that you need to press ctrl + shift + scoll up/down and then RE-PRESS shift to toggle the action again. I mean it's annyong. Also this does not block the scroll, so you might want to scroll on a neutral place (like a sidebar).



                This uses pynput but I hope that won't be a problem






                share|improve this answer













                As far as my reseach went, I wasn't able to find any elegant solution to the problem. I hacked a very crude python script that does the job poorly... I'm sorry.



                from pynput import keyboard
                from pynput import mouse
                from pynput.keyboard import Controller
                import subprocess
                from subprocess import call

                kbd = Controller()

                COMBINATIONS = [keyboard.Key.ctrl, keyboard.Key.shift]

                current = set()

                def execute():
                with mouse.Listener(on_scroll=on_mscroll) as listener:
                listener.join()

                def on_press(key):
                if any([key in COMBO for COMBO in COMBINATIONS]):
                current.add(key)
                if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS):
                # this executes only once and then it looses the keycombination
                execute()

                def on_release(key):
                if any([key in COMBO for COMBO in COMBINATIONS]):
                try:
                current.remove(key)
                except KeyError:
                pass

                def on_mscroll(x, y, dx, dy):
                if dy < 0:
                # this can be changed to the appropriate command to change the volume
                # like pactl
                call(["amixer", "-D", "pulse", "sset", "Master", "5%-"],stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
                else:
                call(["amixer", "-D", "pulse", "sset", "Master", "5%+"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
                return False

                with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
                listener.join()


                The problem with this is that you need to press ctrl + shift + scoll up/down and then RE-PRESS shift to toggle the action again. I mean it's annyong. Also this does not block the scroll, so you might want to scroll on a neutral place (like a sidebar).



                This uses pynput but I hope that won't be a problem







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 27 at 17:14









                mnestorovmnestorov

                264




                264



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503302%2fcreate-a-schortcut-for-keyboard-key-scroll%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown






                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?