macOS: Allow mouse buttons 4 and 5 to navigate history
- VSCode Version: 1.2.1
- OS Version: All
Some mice have "forward" and "back" buttons in addition to the standard ones. Would be nice to to be able to bind those to VSCode's navigateForward/navigateBack actions.
From my experience, this is highly dependant on one's mouse setup. ~~Most mice I have seen have the default setup has those mouse buttons mapped to the keys: alt+left, alt+right for back, and forward respectively.~~
Edit: I just realized that Windows actually emits a dedicated virtual key code for those buttons, Usually named something to the effect of VK_BROSWER_BACK this is what vscode listens for, not alt+left... by default that is...
I have a Logitech G7000s which has 8 buttons addition button. Logitech ships it with software that lets you map what happens when you press a key. I would check your mouse's manufacture to see what they have available. If there's nothing of use/usable on your OS, there's a bunch of software out there to help you do it manually.
Having switched to Linux a month or so back, I had the fun experience of using xbindkeys to listen for the mouse button to be pressed, and then using xte to emit the corresponding series of virtual keystrokes.
Note that currently we only support these buttons on Windows. There they are bound to navigating in the history.
+1 for linux support. I'd love to have the default behavior match that of other applications, or at least be customizable (e.g. browsers, eclipse).
it's driving me crazy when I follow a definition and then want to jump back to where I was. Right now it just changes the indent on the current line. (I've been loving and abusing this in slack lately :P)
@g5codyswartz for temporary fix you can use ctrl-o ctrl-i vim bindings with vim plugin. But having this on mouse too would be pretty sweet. (gd for jumping to definition)
Still not implement in Electron (see https://github.com/electron/electron/issues/6996) but this node module was made especially to tackle this issue. Could it be used for VS-Code to solve this?
+1 for macOS too. Is there any reason this has to be platform-specific?
Be great to get this in Linux. I've managed to translate across all of my IntelliJ shortcuts except for this one (Microsoft ergonomic sculpt mouse).
Is there at least a general way of mapping mouse buttons to actions? Like if the button was just received as "button 4" or something?
For all: please look at the beginning of the thread! This issue cannot be solved (apparently) from the VSCode side, it is (currently) a limitation from electron!
If anyone looking for Linux solution: xbindkeys and xdotool can be used to trigger keyboard sequence on mouse clicks. This is what I'm using:
~/.xbindkeysrc
"xdotool key alt+Left"
b:9
"xdotool key alt+Right"
b:8
@skyjur That's a cute solution, but won't be satisfactory for most people I guess; nobody wants a special keyboard shortcut to be system-wise if it should only be used from within a single software! (but maybe I'm just a little bit too picky…)
If you are using BetterTouchTool on Mac you can map the mouse shortcuts to keyboard shortcuts specific to VSCode application, like button4 to Cmd [ for navigating back in VSCode.
It works like a charm for me :)

It can't be hard to make these bindable in Linux, and especifically in Electron apps, since my back button works fine in Chrome/Chromium to begin with (and elsewhere, including PhpStorm).
@skyjur unfortunately that won't help Wayland users I'm afraid. This should totally be doable in the app without any hacks.
@luispabon
It can't be hard to [...] in Linux
😂
;)
@skyjur thanks for the suggestion. Although I'm not completely comfortable doing this, I cannot dispense with mouse-based navigation. I'd to switch the order for Logitech MX Master 2 on Ubuntu 16.04 though.
That is,
"xdotool key alt+Left"
b:8
"xdotool key alt+Right"
b:9
Seriously, this doesn't need any X hacks to work properly. Chrome and chromium work fine with mouse navigation buttons and have done so for years. Something's not wired up properly on the vscode codebase itself.
That it works in Chrome doesn't automatically mean that it'd work in Electron apps.
For what it's worth, the mouse buttons work in Slack and Spotify Windows clients (which are Electron apps AFAIK) but not in Linux clients.
The related Electron issue was already linked here https://github.com/electron/electron/issues/6996