Hello,
I have a quiet keyboard, so for fun I would sometimes like to enable a satisfying mechanical switch sound whenever a key is pressed, such as https://freesound.org/people/Jagadamba/sounds/254286/
I have figured out how to make the sound play using SoundPlay, C:\mechanical-switch.wav, but making it work for every key is over my head.
How to play sound on every keypress regardless of key and without affecting its function
Re: How to play sound on every keypress regardless of key and without affecting its function
Code: Select all
~a::c()
~b::c()
~c::c()
c(){
Soundplay, C:\mechanical-switch.wav
Return
}
BTW, the sounds "preview"-file is listed within the source code: http://freesound.org/data/previews/254/ ... 622-lq.mp3
Last edited by BoBo on 05 Jul 2017, 07:37, edited 3 times in total.
-
- Posts: 33
- Joined: 09 Apr 2016, 22:14
Re: How to play sound on every keypress regardless of key and without affecting its function
Look at KeyPressOSD for some sample code - https://autohotkey.com/boards/viewtopic.php?t=225
Code: Select all
Loop, 95
{
k := Chr(A_Index + 31)
k := (k = " ") ? "Space" : k
Hotkey, % "~*" k, OnKeyPressed
Hotkey, % "~*" k " Up", _OnKeyUp
}
Loop, 24 ; F1-F24
{
Hotkey, % "~*F" A_Index, OnKeyPressed
Hotkey, % "~*F" A_Index " Up", _OnKeyUp
}
Loop, 10 ; Numpad0 - Numpad9
{
Hotkey, % "~*Numpad" A_Index - 1, OnKeyPressed
Hotkey, % "~*Numpad" A_Index - 1 " Up", _OnKeyUp
}
Otherkeys := "WheelDown|WheelUp|WheelLeft|WheelRight|XButton1|XButton2|Browser_Forward|Browser_Back|Browser_Refresh|Browser_Stop|Browser_Search|Browser_Favorites|Browser_Home|Volume_Mute|Volume_Down|Volume_Up|Media_Next|Media_Prev|Media_Stop|Media_Play_Pause|Launch_Mail|Launch_Media|Launch_App1|Launch_App2|Help|Sleep|PrintScreen|CtrlBreak|Break|AppsKey|NumpadDot|NumpadDiv|NumpadMult|NumpadAdd|NumpadSub|NumpadEnter|Tab|Enter|Esc|BackSpace"
. "|Del|Insert|Home|End|PgUp|PgDn|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|Pause|sc145|sc146|sc046|sc123"
Loop, parse, Otherkeys, |
{
Hotkey, % "~*" A_LoopField, OnKeyPressed
Hotkey, % "~*" A_LoopField " Up", _OnKeyUp
}
Who is online
Users browsing this forum: AHKStudent, boiler, Google [Bot], roysubs and 56 guests