# How to stop system 'boink' sound

**URL:** <https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707>\
**Category:** macOS\
**Created:** [December 7, 2014, 8:24am UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707 "2014-12-07T08:24:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [December 7, 2014, 8:24am UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707/1 "2014-12-07T08:24:48Z")

</div>

I have canvas and want to ‘scroll a picture’ (not really, but that what it look like), when the user presses the left, up, down, and right arrows.

The canvas doesn’t keep the focus, so the keydown events get caught by one or two other controls like list boxes.

In the listbox key down event, I check for these keys, and in response, I set the value of on of two scrollbars  
These cause the canvas to redraw.

` dim b as boolean = false
  If Keyboard.AsyncKeyDown(125) then
    //do something with the down arrow key...
    if vscroll.value < vscroll.Maximum then vscroll.value = vscroll.value +10
    b=true
  end if
  If Keyboard.AsyncKeyDown(126) then
    //do something with the Up arrow key...
    if vscroll.value > 0 then vscroll.value = vscroll.value -10
    b=true
  end if
  if b then return true`

And although this feels very kludgy, it works.

However, the mac goes BOINK (no other word to describe it) when the key press is executed.  
Like WIndows might go Ding

I can’t find any calls to anything like “Beep” in my code.  
Can anyone think of what it is that causes the sound to play?

---

<div class="post-metadata">

**Author:** ![Markus\_Winter](https://forum.xojo.com/user_avatar/forum.xojo.com/markus_winter/32/144_2.png) [@Markus\_Winter](https://forum.xojo.com/u/Markus_Winter)\
**Post date:** [December 7, 2014, 8:50am UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707/2 "2014-12-07T08:50:15Z")

</div>

I think you get that sound when you press a key that the control which receives the key can’t handle.

---

<div class="post-metadata">

**Author:** ![Eli\_Ott](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/5f8ce5/32.png) [@Eli\_Ott](https://forum.xojo.com/u/Eli_Ott)\
**Post date:** [December 7, 2014, 8:55am UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707/3 "2014-12-07T08:55:56Z")

</div>

[code]Const UpKey = 30  
Const DownKey = 31

Dim retval As Boolean = False

If Asc(key) = DownKey then  
//do something with the down arrow key…  
…  
retval = True  
ElseIf Asc(key) = UpKey then  
//do something with the up arrow key…  
…  
retval = True  
End

Return retval[/code]

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 7, 2014, 9:13am UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707/4 "2014-12-07T09:13:41Z")

</div>

> [@148954:@Jeff Tullin](#):
>
> Can anyone think of what it is that causes the sound to play?

Are you sure you return true in all the keydowns ? This is typical of a keydown that the framework cannot handle.

---

<div class="post-metadata">

**Author:** ![Markus\_Winter](https://forum.xojo.com/user_avatar/forum.xojo.com/markus_winter/32/144_2.png) [@Markus\_Winter](https://forum.xojo.com/u/Markus_Winter)\
**Post date:** [December 7, 2014, 9:18am UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707/5 "2014-12-07T09:18:05Z")

</div>

> [@](#):
>
> if b then return true

Else?

---

<div class="post-metadata">

**Author:** ![shao\_sean](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shao\_sean](https://forum.xojo.com/u/shao_sean)\
**Post date:** [December 7, 2014, 9:29am UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707/6 "2014-12-07T09:29:11Z")

</div>

His code should just be “Return b” at the end instead of that if statement

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [December 7, 2014, 9:33am UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707/7 "2014-12-07T09:33:49Z")

</div>

[quote=148954:@Jeff Tullin]The canvas doesn’t keep the focus, so the keydown events get caught by one or two other controls like list boxes.

[/quote]

This looks like a potential source of boinks (you can set up alert in Preferences from submarine to tink). If you start catching keydown in several places, you must make sure to return true in every place to avoid an alert.

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [December 7, 2014, 11:20am UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707/8 "2014-12-07T11:20:41Z")

</div>

> [@](#):
>
> His code should just be “Return b” at the end instead of that if statement

Thanks. That doesn’t fix or change anything but its nice to know theres always another way to write code.

> [@](#):
>
> If you start catching keydown in several places, you must make sure to return true in every place to avoid an alert.

Sounds reasonable. I’ll start tracking them all down and report back

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [December 7, 2014, 11:49am UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707/9 "2014-12-07T11:49:43Z")

</div>

Found a couple of places that were still getting the event.  
Wasn’t causing an issue apart from that awful sound.  
But refactoring everything through one method enabled me to quickly add one key zooming into the equation too, so happy now.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:30pm UTC](https://forum.xojo.com/t/how-to-stop-system-boink-sound/20707/10 "2020-10-29T17:30:56Z")

</div>


