# Is there any way using keymap when 'editable' of the view is false

**URL:** <https://discuss.prosemirror.net/t/is-there-any-way-using-keymap-when-editable-of-the-view-is-false/3317>\
**Category:** Uncategorized\
**Created:** [December 2, 2020, 10:10am UTC](https://discuss.prosemirror.net/t/is-there-any-way-using-keymap-when-editable-of-the-view-is-false/3317 "2020-12-02T10:10:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zlv-thisF](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/zlv-thisf/32/1562_2.png) [@zlv-thisF](https://discuss.prosemirror.net/u/zlv-thisF)\
**Post date:** [December 2, 2020, 10:10am UTC](https://discuss.prosemirror.net/t/is-there-any-way-using-keymap-when-editable-of-the-view-is-false/3317/1 "2020-12-02T10:10:18Z")

</div>

hey, guys!

I have checked the soucecode, seems key events only works when editorView’s editable is **true**.

However I would like to keep the ‘Mod-A’ shortcut to select the document in readonly mode (editable: false) just as what it does in editable mode

any ideas ?

 ![image](https://discuss.prosemirror.net/uploads/secondsite/original/2X/f/fde23271da1b98671afcddc846b5d977e8c311dd.png)

---

<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:** [December 2, 2020, 11:00am UTC](https://discuss.prosemirror.net/t/is-there-any-way-using-keymap-when-editable-of-the-view-is-false/3317/2 "2020-12-02T11:00:49Z")

</div>

With `editable: false`, the `contenteditable` attribute on the document node is removed, which by default makes the browser disable keyboard focus for the element. When the node isn’t focused, it doesn’t even receive keyboard events, so it’s hard to implement any keybindings for it.

You could use the [`attributes` prop](https://prosemirror.net/docs/ref/#view.EditorProps.attributes) to add a [`tabIndex=0`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex) attribute to your editor to make it focusable. But this might lead to some other key bindings also firing, and if those _do_ change the document, `editable: false` (which works only on the DOM) level won’t stop them.

---

<div class="post-metadata">

**Author:** ![zlv-thisF](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/zlv-thisf/32/1562_2.png) [@zlv-thisF](https://discuss.prosemirror.net/u/zlv-thisF)\
**Post date:** [December 2, 2020, 11:19am UTC](https://discuss.prosemirror.net/t/is-there-any-way-using-keymap-when-editable-of-the-view-is-false/3317/3 "2020-12-02T11:19:17Z")

</div>

wow, thanks a lot !

I am wandering that i should accomplish that by createRange and getSelection API when it’s readonly.

---

<div class="post-metadata">

**Author:** ![prosed](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@prosed](https://discuss.prosemirror.net/u/prosed)\
**Post date:** [June 11, 2025, 11:14pm UTC](https://discuss.prosemirror.net/t/is-there-any-way-using-keymap-when-editable-of-the-view-is-false/3317/4 "2025-06-11T23:14:03Z")

</div>

I haven’t had success with keymap when the editor is non-editable, even when I set a `tabIndex` and confirm it’s focused with `document.activeElement === document.querySelector('.ProseMirror')` returning true.

I’ve had to resort to `handleDOMEvents.keydown` but this is messy and duplicative.

@marijn I wonder if you’re certain that the approach you outlined should work, or if there might be something more required? If you’re sure then I guess I have some issue I’m overlooking.

---

<div class="post-metadata">

**Author:** ![prosed](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@prosed](https://discuss.prosemirror.net/u/prosed)\
**Post date:** [June 11, 2025, 11:24pm UTC](https://discuss.prosemirror.net/t/is-there-any-way-using-keymap-when-editable-of-the-view-is-false/3317/5 "2025-06-11T23:24:19Z")

</div>

@marijn the “issue” seems to be in these lines:

> <https://github.com/ProseMirror/prosemirror-view/blob/a72140e2113aebbd4c76d88ab43cbe7dfc838dd7/src/input.ts#L48-L51>

Specifically that `!(event.type in editHandlers)` resolves to `false`.

Is there some way around this you’d recommend?

* * *

The use case is that we trigger a find-box via ProseMirror keymap, which remains relevant even though the editor is non-editable.

---

<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:** [June 12, 2025, 8:29am UTC](https://discuss.prosemirror.net/t/is-there-any-way-using-keymap-when-editable-of-the-view-is-false/3317/6 "2025-06-12T08:29:48Z")

</div>

Indeed, `keymap` uses the `handleKeyDown` prop, which is part of the library’s built-in handling of key events. This is disabled for uneditable editors on the assumption that a lot of keybindings will change the document in ways you don’t want to happen in a read-only editor. “Raw” event handlers registered through [`handleDOMEvents`](https://prosemirror.net/docs/ref/#view.EditorProps.handleDOMEvents) _will_ fire, and you can tie something like a keymap into them using the [`keydownHandler`](https://prosemirror.net/docs/ref/#keymap.keydownHandler) helper from prosemirror-keymap. Maybe that’s a workaround that helps here?
