Keyboard input generating system alerts

Hi Chris,

I’m getting a system alert sound whenever I press a key when using keyboard input in my experiment. It happens for any key, not just the ones I’m listening to. It doesn’t happen in your example from github. Do you have any idea what could be causing this?

Thanks,
Evan

Hi Evan,

MWorks monitors key presses at a low level. It doesn’t use any of the normal application-level text input services. The alert you’re hearing is the result of the key stroke being delivered to an application that doesn’t want to handle it. (The actual event chain may be more complicated than that; I don’t recall the specifics at the moment.)

Whether you hear the alert depends on which application (or specific application window) is active. Using my keyboard input example, I hear the alert when the following windows/applications are active:

  • MWServer main window
  • MWClient main window
  • Calendar

On the other hand, I don’t hear the alert when these windows are active:

  • Server Console
  • Variables window
  • MATLAB window
  • Finder

An easy, global solution is to turn the alert sound off. (Go to System Preferences → Sound and set “Alert volume” to zero.) If you don’t want to do that, then you can just choose an active window that doesn’t emit the alert.

Cheers,
Chris

I’m not sure which of these solutions I prefer, but they both seem clunky, the first because I share the system with other users (who might want to hear system alerts) and choosing the correct active window seems like something that would be easy to mess up. Can MWorks turn off the system alert volume while an experiment is running? Or at least, can the MWorks windows not throw alerts when keys are pressed?

Can MWorks turn off the system alert volume while an experiment is running?

No, I don’t believe so. (At least, I haven’t been able to find a way.)

Or at least, can the MWorks windows not throw alerts when keys are pressed?

I’ve spent some time trying to implement this. Preventing alerts in the server window is straightforward, but doing so in the client window is not and would require some ugly and brittle hacks. Even if I did make these changes, it would remain true that whether you get the beeps depends on which window has focus, so I don’t think this is the right solution anyway.

Sorry, but I think you’ll have to accept one of my previous suggestions.

Chris