# Trying to capure cmd+s/ctrl+s does not work if you paste, triggers the file browser

**URL:** https://discuss.codemirror.net/t/trying-to-capure-cmd-s-ctrl-s-does-not-work-if-you-paste-triggers-the-file-browser/6348
**Category:** v6
**Created:** [April 23, 2023, 7:43pm UTC](https://discuss.codemirror.net/t/trying-to-capure-cmd-s-ctrl-s-does-not-work-if-you-paste-triggers-the-file-browser/6348 "2023-04-23T19:43:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![paladox](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/paladox/32/3274_2.png) [@paladox](https://discuss.codemirror.net/u/paladox)
#### Post date: [April 23, 2023, 7:43pm UTC](https://discuss.codemirror.net/t/trying-to-capure-cmd-s-ctrl-s-does-not-work-if-you-paste-triggers-the-file-browser/6348/1 "2023-04-23T19:43:22Z")

</div>

Hi, we capture ctrl+s/cmd+s here [gerrit/gr-editor-view.ts at master · GerritCodeReview/gerrit · GitHub](https://github.com/GerritCodeReview/gerrit/blob/master/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts#L154)

But that works intermittent with codemirror v6 (worked with v5). When we paste it doesn’t work immediately, instead triggers the file browser. Waiting a few seconds works. If you manually type on the keyboard it works immediately. Wondering if you know why or if this could be a bug in CodeMirror?

The cm code is [plugins\_codemirror-editor/codemirror-element.ts at master · GerritCodeReview/plugins\_codemirror-editor · GitHub](https://github.com/GerritCodeReview/plugins_codemirror-editor/blob/master/web/element/codemirror-element.ts#L102)

I’ve tried to follow [Capturing Ctrl-S doesn't work, opens browser's save dialog](https://discuss.codemirror.net/t/capturing-ctrl-s-doesnt-work-opens-browsers-save-dialog/5228) but it either prevents [gerrit/gr-editor-view.ts at master · GerritCodeReview/gerrit · GitHub](https://github.com/GerritCodeReview/gerrit/blob/master/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts#L154) or doesn’t work exactly.

---

<div class="post-metadata">

### Author: ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)
#### Post date: [April 24, 2023, 1:49pm UTC](https://discuss.codemirror.net/t/trying-to-capure-cmd-s-ctrl-s-does-not-work-if-you-paste-triggers-the-file-browser/6348/2 "2023-04-24T13:49:43Z")

</div>

Can you set up a minimal demo that shows this? I cannot reproduce it in [this setup](https://codemirror.net/try/?c=aW1wb3J0IHtFZGl0b3JWaWV3LCBiYXNpY1NldHVwfSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2tleW1hcH0gZnJvbSAiQGNvZGVtaXJyb3IvdmlldyIKCm5ldyBFZGl0b3JWaWV3KHsKICBleHRlbnNpb25zOiBbCiAgICBrZXltYXAub2YoW3trZXk6ICJjdHJsLXMiLCBydW46ICgpID0+IHsgY29uc29sZS5sb2coIlMiKTsgcmV0dXJuIHRydWUgfX1dKSwKICAgIGJhc2ljU2V0dXAKICBdLAogIHBhcmVudDogZG9jdW1lbnQuYm9keQp9KQo=).

---

<div class="post-metadata">

### Author: ![paladox](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/paladox/32/3274_2.png) [@paladox](https://discuss.codemirror.net/u/paladox)
#### Post date: [April 24, 2023, 3:01pm UTC](https://discuss.codemirror.net/t/trying-to-capure-cmd-s-ctrl-s-does-not-work-if-you-paste-triggers-the-file-browser/6348/3 "2023-04-24T15:01:24Z")

</div>

Seems I found a workaround:

```auto
              // There is an issue where you paste and immediately
              // press ctrl+s/cmd+s after, it would trigger the
              // web browsers file browser rather then gr-editor-view
              // intercepting ctrl+s/cmd+s.
              if ((e.metaKey || e.ctrlKey) && e.key == 'v') {
                e.stopPropagation();
              }

```

Putting that into EditorView.domEventHandlers (keydown) seems to fix the issue.
