Playing a sound on keyDown when livecode is not in front

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
theotherbassist
Posts: 115
Joined: Thu Mar 06, 2014 9:29 am

Playing a sound on keyDown when livecode is not in front

Post by theotherbassist » Tue Mar 22, 2016 5:48 pm

I'm looking to trigger sounds (players--as I have several "channels") on keyDown. But the thing is, I want to do it "in the background"--that is to say when Livecode (my standalone) is up and running but not the front window application. Not possible?--seems it might be.

Let's say for simplicity's sake that I want to make a "typewriter" add-on for fun ( :wink: ) word processing. So I want Livecode to play a sound (yeah, I know latency is an issue) whenever a key is pressed, to reproduce the sonic experience of writing via a typewriter. Presumably the user would want to type in his or her own word processor and run the typewriter sounds standalone simultaneously but just for effect.

I've read some posts on here about "keylogging" and "listening for keys" by setting up "a timer that listens to the keysDown" and then using some kind of window switching to add the keys to an object in the livecode window. I don't even want to do anything as complicated as record the keys--just play a sound. This must be possible through a similar method to http://forums.livecode.com/viewtopic.php?f=9&t=4421 but some of the links on that thread are broken and I don't quite understand. Thanks for any help you can offer!


theotherbassist
Posts: 115
Joined: Thu Mar 06, 2014 9:29 am

Re: Playing a sound on keyDown when livecode is not in front

Post by theotherbassist » Wed Mar 23, 2016 1:51 am

Yes, I have read that thread. However... the link placed in my original post seems to suggest otherwise--Klaus even appeared to recognize his mistake (if, in fact, I'm interpreting it correctly).

theotherbassist
Posts: 115
Joined: Thu Mar 06, 2014 9:29 am

Re: Playing a sound on keyDown when livecode is not in front

Post by theotherbassist » Thu Apr 07, 2016 11:31 pm

I'll just follow up on this by saying I got it to work using a timer that checks for the keys down.

Given that sounds are always a little laggy in the livecode engine, I wrote the sound functions into the html/javascript of a local web page loaded into a livecode browser window. Response time was instantaneous, but unfortunately the timer does not trigger the javascript when the window is not in focus.

Post Reply