Double-tap SpaceKey selection bug (MAC)

Hey

If you double tap the spacebar on mac the selection moves 2 spaces to the right and inserts a period. (This also happens in the ProseMirror demos)

Is there a way to disable this?

We have tried the following:

A custom handleKeyDown function for the space key.

We then added our own custom handler that adds a single space character…

  const spaceMark = view.state.schema.marks.space.create();
  const spaceEntity = view.state.schema.text(' ', [spaceMark]);

  let transaction = view.state.tr;

  transaction.replaceWith(view.selection.from, view.selection.to, [ spaceEntity ]);

  dispatch(transaction);

  return true;

This prevents the period from being added but the selection still moves to the right. Are we missing something or is this a bug… The second event gives an event.keyCode of 229 - I have tried canceling this too.

It looks like codepen have managed to disable this. It must be something that is able to be overridden. Any help would be great.

Thanks for the awesome library!

1 Like

That’s how selection mapping works in ProseMirror — if you insert something at the cursor, it is by default moved forward, after the new content.

Yes. But we are finding that when double tapping space it moves the cursor 2-3 characters to the right when only adding one character.

For instance… in the proseMirror website example double tap adds [space][period][space] whereas we want double tap to add [space][space] independently.

Thanks for the quick reply btw.

This problem appears to only be there in Chrome, not in Safari, and happens in Chrome in plain contentEditable elements as well, so I’m going to say that it’s a Chrome bug that’s unrelated to ProseMirror.

1 Like