Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on Karabiner-Elements #38

Merged
merged 17 commits into from
Jun 22, 2018
Merged

Conversation

jasonrudolph
Copy link
Owner

tl;dr - Hyper Mode is now triggered by tapping the option key, and you'll need to use the macOS system preferences if you want to remap caps lock to control.

Motivation

A few times each day, I experience a strange issue where my keyboard stops responding for a few seconds, and then a stream of twenty or so keystrokes occur all at once. I'm not sure what's causing it, and I don't know how to reliably reproduce it (other than just using my Mac for a few hours and waiting for it to happen 😓).

I don't know if it's a bug in Karabiner-Elements, a bug in this repository, or a problematic interaction between my Hammerspoon customizations and Karabiner-Elements. 🤷‍♂️ However, I disabled Karabiner-Elements for a week, and I didn't experience the issue at all. I then re-enabled Karabiner-Elements, and I started seeing the issue again.

Since most of this repository's customization uses Hammerspoon, and I only use Karabiner-Elements for two small(ish) things, I'm making the bittersweet decision to remove Karabiner-Elements.

User-facing changes

Tap option to enter Hyper Mode

I previously used Karabiner-Elements to map the right option key to a "hyper" key. Hammerspoon can't distinguish between the right option key and the left option key, and it wouldn't make sense to override both keys, so we need another approach for triggering Hyper Mode.

With the changes in this pull request, you'll now tap option (AKA alt) to enter Hyper Mode and then press any shortcut to focus the associated application. For example, if you're using the default keybindings to open the Finder, you would:

  1. Tap the option key (i.e., press and then release it in quick succession) to enter Hyper Mode
  2. Then, press f for Finder

With this approach, we avoid interfering with existing macOS shortcuts and application shortcuts that make use of the option key, and we still have a way to define global shortcuts for launching apps.

Use macOS system preferences to remap caps lock to control

I previously used Karabiner-Elements to map caps lock key to control. Hammerspoon can't do that, but it's a quick, one-time change that you can make via macOS system preferences:

Open System Preferences, navigate to Keyboard > Modifier Keys, and set the caps lock key to control [screenshot]

With that customization in place, you can once again tap caps lock for escape and hold caps lock for control.

- Hyper Mode is now activated by simultaneously pressing the 'k' and 'l'
  keys and holding them down. This is similar to activating (S)uper
  (D)uper Mode by simultaneously pressing the 's' and 'd' keys and
  holding them down.
- Hyper Mode is no longer activated by pressing the right option key.
- The format of the Hyper Mode key-to-app mappings has changed.
  See hammerspoon/hyper-apps-defaults.lua.
b6e7d24 removed the use of
Karabiner-Elements for triggering Hyper Mode, and opted to trigger Hyper
Mode with a simultaneous keypress of 'k' and 'l'. After using that
behavior for a few days, it's not the experience I'm looking for.

I think tapping 'alt' will be closer to the experience I'm looking for.
Tapping 'alt' is super easy to do. (It's easier than ensuring that you
hit k and l simultaneously.) Also, when typing, you use 'alt' a lot
less often than you use 'k' and 'l', so using 'alt' reduces the chance
that you'll accidentally trigger Hyper Mode when you're just trying to
type.

- Remove the new code introduced in b6e7d24
- Add logic to enter Hyper Mode when you press and then release the
  'alt' key
- Restore the original format of the Hyper Mode key-to-app mappings. 😅
  See hammerspoon/hyper-apps-defaults.lua.
@viddo
Copy link

viddo commented May 6, 2018

Yay, I had been thinking about looking into this too. 👍

I believe it's a bug on Karabiner-Elements, there are at least two long issues with reports:

@jasonrudolph
Copy link
Owner Author

@viddo: Thanks for sharing links to those issues. 🙇💟

@jnunemaker
Copy link
Contributor

I think this is actually better for me as well. Currently I have a profile for my laptop keyboard and my external keyboard. Merging this means the global caps => control setting, which I use to use, but removes having multiple profiles and needing to swap them. The only thing I was worried about was tap control for escape but that works through hammerspoon so this seems good to me. 👍

Prior to this change, simultaneously tapping option and another modifier
would sometimes enter Hyper Mode. With this change, we should only enter
Hyper Mode when this exact sequence occurs:

1. No modifiers are down
2. Only the Option key is down
3. No modifiers are down
Prior to this change, if you used Hyper Mode multiple times in quick
succession, the timer from the _previous_ Hyper Mode invocation could
cause the _current_ Hyper Mode invocation to exit. Whoops.
Fixes the following bug:

1. Hold down option+shift
2. Press left arrow
3. Release shift
4. Release option
5. Observe that it wrongly enters Hyper Mode
@jasonrudolph jasonrudolph merged commit bd2f8ff into master Jun 22, 2018
@jasonrudolph jasonrudolph deleted the 🔥-karabiner branch June 22, 2018 21:05
jasonrudolph added a commit that referenced this pull request Jul 18, 2018
This reverts commit bd2f8ff, reversing
changes made to 3601e5e.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants