Page 1 of 1

Key click sound

Posted: Thu Oct 04, 2007 12:30 am
by John_Schofield
Does anyone have a code snippet which would generate a click sound each time a key is pressed when typing a string of characters?

I can make a beep when I press "Enter" or but I'd like to be able to hear a click each time a key is pressed as a string is built up as well.

Is that possible?

Cheers!

Key click sound

Posted: Thu Oct 04, 2007 10:55 am
by Valerie
Hello again John.

This is probably not what you want but the best I have come up with so far:

Code: Select all

CLS

DO
a$ = INPUT$(1)
  PLAY "T255 L64 g-"
  b$ = b$ + a$
  LOCATE 1, 1: PRINT b$
LOOP

Note that the loop is closed, leave it up to you to sort out an appropriate exit. You can also adjust the speed and key to suit.

Regards

Valerie.

Posted: Thu Oct 04, 2007 1:02 pm
by John_Schofield
Thanks Valerie

Much appreciated.

I have another solution I thought of last night so I'll try them both!

Regards

Posted: Thu Oct 04, 2007 7:28 pm
by Ralph
Hello, Valerie. I don't know why the PLAY line didn't respond for me. I changed that line to
SOUND 255,1
and that worked well.

Posted: Thu Oct 04, 2007 11:25 pm
by Valerie
Hello Ralph.

I don't understand why Play didn't work for you either. I'm getting the click thru' my soundcard not from the inbuilt speaker.

I had tried Sound before posting but thought that Play was a tad faster, am probably wrong on that. Also Play gives me more of a click than a tone.

Beep also works for me but is only good for very s-l-o-w typing.

BTW am using QB 4.5 in XP Home cmd.exe although Command.com made only one difference, that being that Beep no longer worked.

Regards

Valerie

Posted: Thu Oct 04, 2007 11:48 pm
by John_Schofield
I've found that Valerie's PLAY instructions gives a pretty quiet click which is ok with a silent keyboard but not my clacky old thing here at home - the keys make more noise!!

By experimentation, I've settled on SOUND 950, .2 as being just about right for my particular requirement in a potentially slightly noisy enviromnent. If I need to make it more audible I just extend the duration to .5 or something and/or slightly reduce the frequency.

Both come out through the built in speaker rather than the sound card, which fits the bill for me.

I've managed to squeeze the SOUND instruction into a section of code I found in an old program which builds a string from key presses so this works fine for me now.

Thanks for your help.

Posted: Sat Oct 06, 2007 5:18 am
by Valerie
Thanks for your response John. As I now am using XP perhaps that has something to do with the soundcard being used. Adjusting the Volume control allows for quiet or deafening clicks.

Glad you found a solution which suits your purpose.

V.

Posted: Sat Oct 06, 2007 3:24 pm
by John_Schofield
cheers - I'm still stuck in the days of Win98 foir my laptop selection!