# Shortcut Ctrl-A / Ctrl-E don't work on macOS with inline node

**URL:** <https://discuss.prosemirror.net/t/shortcut-ctrl-a-ctrl-e-dont-work-on-macos-with-inline-node/4328>\
**Category:** Uncategorized\
**Created:** [January 11, 2022, 8:00pm UTC](https://discuss.prosemirror.net/t/shortcut-ctrl-a-ctrl-e-dont-work-on-macos-with-inline-node/4328 "2022-01-11T20:00:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ocavue](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/ocavue/32/2239_2.png) [@ocavue](https://discuss.prosemirror.net/u/ocavue)\
**Post date:** [January 11, 2022, 8:00pm UTC](https://discuss.prosemirror.net/t/shortcut-ctrl-a-ctrl-e-dont-work-on-macos-with-inline-node/4328/1 "2022-01-11T20:00:30Z")

</div>

There are two pairs of shortcuts that can move the cursor to the start/end of the current line.

> [Mac keyboard shortcuts - Apple Support](https://support.apple.com/en-us/HT201236)
> 
> - Command–Left Arrow: Move the insertion point to the beginning of the current line.
> - Command–Right Arrow: Move the insertion point to the end of the current line.
> 
> * * *
> 
> - Control-A: Move to the beginning of the line or paragraph.
> - Control-E: Move to the end of a line or paragraph.

They have a subtle difference when the paragraph has multiple lines, but that’s nothing to do with the following issue.

When you have a `contenteditable="false"` inline node inside your paragraph, Cmd-Left/Right works well but Ctrl-A/E will be stuck at the boundary of the inline node.

[https://user-images.githubusercontent.com/24715727/149011827-c6f9fd81-233e-4796-a9fd-2c717be3ccb2.mp4](https://user-images.githubusercontent.com/24715727/149011827-c6f9fd81-233e-4796-a9fd-2c717be3ccb2.mp4)

I don’t think ProseMirror has anything to do with this issue, because

1. ProseMirror doesn’t bind to these shortcuts.
2. This issue only occurs on Safari and Chrome. Firefox works fine without any issue.
3. I can reproduce it with a simple HTML that contains an editable div.

```html
<body>
    <div id="root" contenteditable="true">
        <p>Just plain HTML: <a class="inline-node" tabindex="-1" contenteditable="false">#tag</a> hello</p>
    </div>
    <style>
        .inline-node {
            color: red;
        }
    </style>
</body>

```

[https://user-images.githubusercontent.com/24715727/149011845-c281df2a-6dc8-49d8-b9c5-6b52662afcee.mp4](https://user-images.githubusercontent.com/24715727/149011845-c281df2a-6dc8-49d8-b9c5-6b52662afcee.mp4)

I haven’t been able to find much discussion on this issue. The only thing I can find is a [post](https://discuss.prosemirror.net/t/how-to-create-non-editable-text-segments-in-the-document/1154) from 4 years ago.

> Some navigational bindings do not quite as expected, for instance Ctrl-e / Ctrl-a jumps to the next / previous code\_inline node instead of end / beginning of the line.

I tried to add keymap and handle Ctrl-A/E with ProseMirror. It seems to works. So I guess I’ve found a workaround for this issue.

Here are some follow-up questions about this issue:

- Any better suggestions for this issue?
- Is it a good idea for me to submit a PR to `prosemirror-commands` and add bindings to `ctrl-a`/`ctrl-e` in `macBaseKeymap`?

* * *

Ps, here is my test environment and result for this issue:

- macOS 11.6.2
  - Chrome 97.0: has issue
  - Safari 15.2: has issue
  - Firefox 96.0: no issue

- iPadOS 15.2:
  - Chrome 96.0: no issue
  - Safari: no issue
  - Firefox 40.2: no issue

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [January 12, 2022, 8:40am UTC](https://discuss.prosemirror.net/t/shortcut-ctrl-a-ctrl-e-dont-work-on-macos-with-inline-node/4328/2 "2022-01-12T08:40:18Z")

</div>

The library currently doesn’t handle ctrl-a/e (or home/end), letting the browser do its native thing. So this would be a browser bug.

---

<div class="post-metadata">

**Author:** ![ocavue](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/ocavue/32/2239_2.png) [@ocavue](https://discuss.prosemirror.net/u/ocavue)\
**Post date:** [January 13, 2022, 3:19am UTC](https://discuss.prosemirror.net/t/shortcut-ctrl-a-ctrl-e-dont-work-on-macos-with-inline-node/4328/3 "2022-01-13T03:19:07Z")

</div>

I agree this is a browser bug. Do you thing it’s a good idea to add coding as workaround for this browser bug in `prosemirror-command` package? I can submit a PR if you want.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [January 13, 2022, 9:28am UTC](https://discuss.prosemirror.net/t/shortcut-ctrl-a-ctrl-e-dont-work-on-macos-with-inline-node/4328/4 "2022-01-13T09:28:50Z")

</div>

Yeah, sorry, you said all I replied already in your original post. I’m a bit hesitant to add more custom key handling, because invariably that will then result in bug reports because the custom handling disagrees with native behavior in subtle ways. But I guess moving to the start/end of the textblock (and returning false when not in a textblock) is likely to be mostly unproblematic. I’d be interested in such a PR, and I guess it should bind home/end on non-macOS platforms as well.

---

<div class="post-metadata">

**Author:** ![ocavue](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/ocavue/32/2239_2.png) [@ocavue](https://discuss.prosemirror.net/u/ocavue)\
**Post date:** [January 17, 2022, 11:41am UTC](https://discuss.prosemirror.net/t/shortcut-ctrl-a-ctrl-e-dont-work-on-macos-with-inline-node/4328/5 "2022-01-17T11:41:39Z")

</div>

I’ve submit the pull request: [Bind Ctrl-a and Ctrl-e on macOS by ocavue · Pull Request #13 · ProseMirror/prosemirror-commands · GitHub](https://github.com/ProseMirror/prosemirror-commands/pull/13)

I didn’t bind home/end as I only see this bug on macOS.

---

<div class="post-metadata">

**Author:** ![andrews](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@andrews](https://discuss.prosemirror.net/u/andrews)\
**Post date:** [January 18, 2022, 10:23pm UTC](https://discuss.prosemirror.net/t/shortcut-ctrl-a-ctrl-e-dont-work-on-macos-with-inline-node/4328/6 "2022-01-18T22:23:38Z")

</div>

You may want to implement shift versions as well then so the extend selection behavior is consistent.
