Help us understand the problem. What is going on with this article?

macOS Sierraで5ボタンマウスを使う

More than 1 year has passed since last update.

Sierra以前ではKarabinerを使っていたが、SierraではKanabinerは使えない。かといってその代替であるKanabiner-elementsでもマウスボタンのバインドは今のところ出来ない。なのでHammerspoonを使って設定する。

local function mousePress(eventobj)

  if eventobj:getButtonState(4) then
    hs.eventtap.event.newKeyEvent({'cmd'}, ']', true):post()
    hs.eventtap.event.newKeyEvent({'cmd'}, ']', false):post()
  end

  if eventobj:getButtonState(3) then
    hs.eventtap.event.newKeyEvent({'cmd'}, '[', true):post()
    hs.eventtap.event.newKeyEvent({'cmd'}, '[', false):post()
  end

  return false
end

hs.eventtap.new({25}, mousePress):start()

こんな感じで設定すればOK。自分は5ボタンのうち2つのボタンをブラウザバックフォワードに割り当てている。Chromeでブラウザバックやフォワードのショートカットキーが ⌘ + [なのでマウスボタンが押されたらそれらのショートカットキーが発火するように設定してる。

参考 https://github.com/tarpdalton/dotfiles/blob/tarp/.hammerspoon/init.lua

追記: 2017/10/4 12:45

キーボードがJIS配列の場合、Hammerspoonが [ などを別のキーと認識してしまうので、上記のスクリプトではうまく動かない。なので下記のような設定が必要。@keroxpさんコメントありがとうございます!
https://qiita.com/shim0mura/items/96fad93b2696bc073d23#comment-f56d88456d43739448ad

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした