Create a schortcut for Keyboard Key + Scroll
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
add a comment |
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
add a comment |
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
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
keyboard-shortcuts
asked Feb 27 at 11:02
Dev AggarwalDev Aggarwal
1012
1012
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Feb 27 at 17:14
mnestorovmnestorov
264
264
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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