9

I have never noticed this before, but it seems like MacOS prevents certain key combinations to be pressed.

For instance, try pressing at the same time the keys z s and c on a standard Qwerty keyboard. This works and should write something like "csz". But if the three keys are all adjacent, for instance z s and x, MacOS drops one or two, or all of them, for instance giving you just "z" or "zx" or nothing at all. I've noticed this consistently across multiple Mac devices.

Since I'm programming a software that heavily relies on various key combinations (it's a virtual MIDI keyboard that transforms the computer keyboard into a MIDI controller), how to disable this behaviour?

5
  • 8
    This is very common on lots of keyboards, it's called rollover
    – minseong
    Commented Mar 16, 2021 at 13:11
  • 3
    cxz dsa hgf cxzbv cxzbvn cxmzbnv - all work for me on 2020 MacBook Pro with the upgraded keyboard design. So not all devices it seems. Commented Mar 16, 2021 at 21:12
  • zsc works fine for me on 2019 MacBook Pro 16", with the builtin keyboard and with the external Apple Magic keyboard.
    – ruohola
    Commented Mar 17, 2021 at 9:31
  • My 2019 15" MBP appears to support 5-key rollover within a single row or column, but 3 keys in 2 rows/2 columns (ex qwx or azx) fail; as do 4 keys in 3r/3c. Commented Mar 17, 2021 at 18:06
  • That sounds like the way the keyboard scan matrix is wired. In the simplest case, imagine the keys wired up with rows and columns; strobe the rows via GPIO output pins and scan the columns using GPIO input pins. If multiple keys are held down, you are "blind" to keypresses in the same row or same col.
    – JDługosz
    Commented Mar 17, 2021 at 18:52

2 Answers 2

21

This is a hardware limitation of the built-in keyboard (and most non-gamer consumer keyboards)

You have to get a separate keyboard which supports NKRO (N-Key Rollover).

There might be issues with macOS compatibility with some n-key rollover keyboards USB keyboard acting strange with MacBook Pro

So check if it's compatible before you buy

6
  • 6
    NKRO = "N-Key Rollover" - rollover is the maximum number of simultaneous keypresses the keyboard is guaranteed to detect correctly: en.wikipedia.org/wiki/Rollover_(key) has more
    – minnmass
    Commented Mar 17, 2021 at 0:07
  • You probably meant ghosting preventing and that is indeed hardware issue for simple keyboard designs. Commented Mar 17, 2021 at 14:08
  • Given Apple's reputation for "just working" I sort of expected they might have fixed this common problem. Commented Mar 17, 2021 at 15:24
  • @AlexeyKamenskiy ghosting prevention is the related function preventing false key presses from being returned when the controller can't figure out which keys were pressed. Most (all??) modern basic keyboard designs jam (ignore some potential key presses) when they can't determine all the keys pressed instead of ghosting. Commented Mar 17, 2021 at 18:14
  • 1
    @user253751 I suspect the competing goals of light and compact is to blame, higher levels of n-key rollover needs additional components (per key diodes), and apparently lighter for the 99% of users who don't do crazy keyboard mashing has won out. Commented Mar 17, 2021 at 18:17
6

Using the macOS Keyboard Viewer gives you a good overview of the problem. If you hold down Z and X, and then try to press other buttons, you'll see that S, A, Q, W, 1 and 2 will not activate, but all other keys will.

Similarly, holding CV stops DFER34 from working. MN stops HJYU67.

enter image description here

You may want to use the low-level keyDown(with:) and keyUp(with:) methods of NSResponder, or other APIs used for gaming keys, before confirming that it's a hardware limitation.

(Note that programming help is off-topic here: try Stack Overflow for further discussion.)

https://code.bitbebop.com/macos-game-keyboard-input/

https://developer.apple.com/documentation/gamecontroller/gckeyboardinput

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .