Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

detect keyrelease events?

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
jointhefree
Posts: 30
Joined: 2014-01-04 14:14

detect keyrelease events?

#1 Post by jointhefree »

Calling on brains faster or wiser than mine, because I've failed with the search engine to find the answer.
I'm trying to get a particular voice chat app (IHearYou, designed for lan) to do what it's not designed to do. It goes by voice activation, but I want key-presses. I don't use the Windows (Super_L) key for anything, so that will be my key. I know several ways of triggering events with a keypress. I want to raise my mic volume to some high level on Super_L keypress events, using alsamixer for the adjustment. Problem is, I need to reduce mic volume to 0 on key RELEASE. Detecting keyreleases must be possible, right? Preferrably in bash? Or if I can run some raw code, that'd probably be fine too.
The only thing I've found so far for monitoring global events is xev, but that creates a window in the front of everything, which would be annoying.

EDIT: I found a solution, but imperfect. Xbindkeys. xbindkeys-config was helpful too for speeding my progress up. So I'll be able to have a script that makes alsamixer adjust the mic volume to 0 when I release a designated key and another script to set it to 30 triggered when I press that key. For some reason, I'm having trouble getting xbindkeys to map a script to the the Windows Super_L key keyrelease, but other keys work, so I'm sure I can get something working here.

Another edit: I also found a xset r off was necessary, as auto-repeat simulates repeated keypresses and releases, causing the mic volume to go up and down many times in a second. Not good.

FINALLY: Here's what I ended up with. a script called toggle-mic-on:
#!/bin/bash
xset -r 78
amixer -q set Digital 60
exit

and a script called toggle-mic-off
#!/bin/bash
xset -r 78
amixer -q set Digital 0
exit

Using xbindkeys-config, I mapped toggle-mic-on to occur when I press the scroll_lock key and toggle-mic-off when I release the scroll_lock key The condition looks like: "Release + Scroll_Lock" . The "xset -r 78" line gets rid of key auto-repeat for just the scroll_lock key. Because I want to keep auto-repeat on the "normal" keys.

Yes, I'm adjusting just the digital. Whatever that means. It seems to be tied with the overall recording volume. Then I adjust my mic, micbst, and capture levels to get them right using audacity. I record (while holding the scroll-lock key) and watch to see if I'm getting a good volume but avoiding red levels.

I really would have preferred to map these events to hotkey triggers using openbox's rc.xml (or in my case, lxde-rc.xml), but I could find nothing in the docs about release events being possible. So, I was forced to use xbindkeys. It works, anyway.
Last edited by jointhefree on 2015-04-01 02:36, edited 10 times in total.

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: detect keyrelease events?

#2 Post by dasein »

jointhefree wrote:...I've failed with the search engine to find the answer.
Really??? I find myself wondering exactly what query terms you used. (And "I tried lots and lots and magically can't remember any of them" just means you that you need to take notes when you redo the searches.)
Last edited by dasein on 2015-03-30 20:45, edited 1 time in total.

jointhefree
Posts: 30
Joined: 2014-01-04 14:14

Re: detect keyrelease events?

#3 Post by jointhefree »

Well, I'm clearly lost. :o Thank you for your considerate helpfulness, you kind man, you. Really, though, am I in the wrong place? I may be. It sure does sound like it.

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: detect keyrelease events?

#4 Post by dasein »

Sharing query terms, rather than invoking the "magic amensia" defense, would have gone a long way toward validating your claim to exhaustive searching.

Maybe have "another" go. I found thousands of hits with a brain-dead obvious query.

jointhefree
Posts: 30
Joined: 2014-01-04 14:14

Re: detect keyrelease events?

#5 Post by jointhefree »

I wanted help, not google tips. I apologize for wasting your time.

jointhefree
Posts: 30
Joined: 2014-01-04 14:14

Re: detect keyrelease events?

#6 Post by jointhefree »

What really puzzles me is the anger I always encounter in here. Is it that certain people feel like a post REQUIRES them to help or respond, meaning that a post by someone far less experienced is therefore an intentional bid to waste their time and effort?

jointhefree
Posts: 30
Joined: 2014-01-04 14:14

Re: detect keyrelease events?

#7 Post by jointhefree »

Reading the thread, I realize now, it may have just been a misunderstanding. My mentioning that I failed in my search made it sound like I was seeking help searching the search engines I suppose. And that would be an oops on me. Sorry about that. It was me who was the angry one. :D I'll blame it on this rare headache I have today.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: detect keyrelease events?

#8 Post by Head_on_a_Stick »

If you use xev that returns key release events ("KeyRelease") so you could grep the output from that.
deadbang

jointhefree
Posts: 30
Joined: 2014-01-04 14:14

Re: detect keyrelease events?

#9 Post by jointhefree »

You mean, to get the key code for the Super_L key? Yeah, I know about xev. No, it seems to be some problem with xkeybind or something. It just doesn't want to map to the Super_L (windows key). Maybe I should try the right Windows key.. I probably already did, but not sure.

Post Reply