# Conditional keymapping not working

**URL:** <https://forum.cursor.com/t/conditional-keymapping-not-working/132490>\
**Category:** Bug Reports\
**Created:** [September 3, 2025, 12:41pm UTC](https://forum.cursor.com/t/conditional-keymapping-not-working/132490 "2025-09-03T12:41:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![digi](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/digi/32/78713_2.png) [@digi](https://forum.cursor.com/u/digi)\
**Post date:** [September 3, 2025, 12:41pm UTC](https://forum.cursor.com/t/conditional-keymapping-not-working/132490/1 "2025-09-03T12:41:08Z")

</div>

### Where does the bug appear (feature/product)?

Cursor IDE

### Describe the Bug

Hi all,  
I’m trying to migrate from VSCode to Cursor, but some of my keyboard shortcuts are just not working as expected (I imported all settings), especially this particular example with a condition on when the shortcut should apply.  
This works in VSCode.

Any thoughts here would be appreciated.  
Thanks.

### Steps to Reproduce

`cmd+1` will not toggle the sidebar when it has focus. It instead returns the focus to the editor.

```auto
  {
    "key": "cmd+1",
    "command": "workbench.view.explorer"
  },
  {
    "key": "cmd+1",
    "command": "workbench.action.toggleSidebarVisibility",
    "when": "viewContainer.workbench.view.explorer.enabled && sideBarFocus"
  },
  {
    "key": "escape",
    "command": "workbench.action.focusActiveEditorGroup",
    "when": "sideBarFocus"
  }

```

### Expected Behavior

When the sidebar is hidden, I want `cmd+1` to open and focus it.  
If I then hit `cmd+1` again (while the sidebar has focus), I want it to close the sidebar.  
If the sidebar is open, but doesn’t have focus, and I hit `cmd+1`, I want it to focus the sidebar.

### Operating System

MacOS

### Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.5.9 (Universal)  
VSCode Version: 1.99.3  
Commit: de327274300c6f38ec9f4240d11e82c3b0660b20  
Date: 2025-08-30T21:02:27.236Z  
Electron: 34.5.8  
Chromium: 132.0.6834.210  
Node.js: 20.19.1  
V8: 13.2.152.41-electron.0  
OS: Darwin arm64 24.6.0

### Does this stop you from using Cursor

No - Cursor works, but with this issue

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [September 3, 2025, 3:29pm UTC](https://forum.cursor.com/t/conditional-keymapping-not-working/132490/2 "2025-09-03T15:29:21Z")

</div>

Hey, try these keybinding settings.

```auto
  {
    "key": "cmd+1",
    "command": "workbench.view.explorer",
    "when": "!sideBarVisible"
  },
  {
    "key": "cmd+1",
    "command": "workbench.action.toggleSidebarVisibility",
    "when": "sideBarVisible && explorerViewletFocus"
  },
  {
    "key": "cmd+1",
    "command": "workbench.view.explorer",
    "when": "sideBarVisible && !explorerViewletFocus"
  },
  {
    "key": "shift+cmd+e",
    "command": "-workbench.view.explorer",
    "when": "viewContainer.workbench.view.explorer.enabled"
  },
  {
    "key": "cmd+b",
    "command": "-workbench.action.toggleSidebarVisibility"
  }

```

---

<div class="post-metadata">

**Author:** ![digi](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/digi/32/78713_2.png) [@digi](https://forum.cursor.com/u/digi)\
**Post date:** [September 3, 2025, 4:16pm UTC](https://forum.cursor.com/t/conditional-keymapping-not-working/132490/3 "2025-09-03T16:16:31Z")

</div>

Perfect, thank you. I see that it was the values I was using in the conditions that was the issue. I updated my `esc` command to utilise this too, so now I have the exact functionality I was expecting. 🙌

```auto
  {
    "key": "escape",
    "command": "workbench.action.focusActiveEditorGroup",
    "when": "sideBarVisible && explorerViewletFocus"
  },

```

---

<div class="post-metadata">

**Author:** ![digi](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/digi/32/78713_2.png) [@digi](https://forum.cursor.com/u/digi)\
**Post date:** [September 3, 2025, 10:07pm UTC](https://forum.cursor.com/t/conditional-keymapping-not-working/132490/4 "2025-09-03T22:07:05Z")

</div>

What’s interesting is that `sideBarFocus` doesn’t seem to work at all, but definitely does in VSCode, even for pretty simple commands (which could’ve been the reason I was struggling with my initial conditional command).

I’ve also seen the same issue when using conditionals such as `activeViewlet == 'workbench.view.debug'`. Is Cursor using different names here compared to VSCode? I don’t see these documented on the website, so I’m assuming I should be going by VSCode’s docs here. Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [September 25, 2025, 10:07pm UTC](https://forum.cursor.com/t/conditional-keymapping-not-working/132490/5 "2025-09-25T22:07:57Z")

</div>

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.
