vscode icon indicating copy to clipboard operation
vscode copied to clipboard

macOS: Allow mouse buttons 4 and 5 to navigate history

Open vadimcn opened this issue 10 years ago • 100 comments

  • 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.

vadimcn avatar Jul 01 '16 20:07 vadimcn

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.

rozzzly avatar Jul 02 '16 02:07 rozzzly

Note that currently we only support these buttons on Windows. There they are bound to navigating in the history.

bpasero avatar Jul 02 '16 06:07 bpasero

+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).

jcogilvie avatar Aug 25 '16 20:08 jcogilvie

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 avatar Mar 03 '17 22:03 g5codyswartz

@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)

karolmie1 avatar May 03 '17 10:05 karolmie1

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?

Naereen avatar Jul 19 '17 12:07 Naereen

+1 for macOS too. Is there any reason this has to be platform-specific?

doppio avatar Jul 26 '17 16:07 doppio

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).

luispabon avatar Sep 14 '17 16:09 luispabon

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?

dbeckwith avatar Oct 16 '17 17:10 dbeckwith

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!

Naereen avatar Oct 17 '17 08:10 Naereen

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 avatar May 09 '18 05:05 skyjur

@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…)

Naereen avatar May 09 '18 21:05 Naereen

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 :)

image

samuelchanx avatar May 16 '18 15:05 samuelchanx

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).

luispabon avatar May 16 '18 16:05 luispabon

@skyjur unfortunately that won't help Wayland users I'm afraid. This should totally be doable in the app without any hacks.

luispabon avatar May 16 '18 16:05 luispabon

@luispabon

It can't be hard to [...] in Linux

😂

rozzzly avatar May 17 '18 13:05 rozzzly

;)

luispabon avatar May 17 '18 13:05 luispabon

@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

aravindbattaje avatar May 22 '18 16:05 aravindbattaje

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.

luispabon avatar May 23 '18 09:05 luispabon

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

noppa avatar May 23 '18 09:05 noppa