Live data from Hacker News

Keyboard tricks from a macOS app dev

notes.alinpanaitiu.com

81–90 of 153 posts

Re: Keyboard tricks from a macOS app dev

#81

I recently purchased a MacBook, and while I'm thoroughly impressed with the hardware, I find the keyboard navigation in the desktop environment somewhat lacking in comparison to my previous experience. Having used Linux Pop OS for many years, I've grown accustomed to the intuitive and powerful tiling window manager and keyboard navigation shortcuts it offers. I'm struggling to find a comparable solution on the macOS…

As another suggestion, Better Touch Tool does great for tiling window manager and adding shortcuts.

It's one of the first things I always need. It started coming from Linux with a similar experience to you.

----

A big shortcut for me is cmd+shift+/

It allows searching on all submenus. So when I'm working on an IDE for example, it's how I find those obscure options I know are there but I don't use frequently enough to remember the shortcut.

Re: Keyboard tricks from a macOS app dev

#82
I use HammerSpoon with the ShiftIt spoon.

https://github.com/peterklijn/hammerspoon-shiftit

I like to move windows around with just my left hand, which doesn't work if you use the right command key.

Instead you can use left_alt + left_command together

The full list of commands I use with the ShiftIt spoon:

  spoon.ShiftIt:bindHotkeys({
    left = {{ 'alt', 'cmd' }, 'z' },
    right = {{ 'alt', 'cmd' }, 'x' },
    up = {{ 'alt', 'cmd' }, 'q' },
    down = {{ 'alt', 'cmd' }, 'a' },
    resizeIn = {{ 'alt', 'cmd' }, '-' },
    resizeOut = {{ 'alt', 'cmd' }, '=' },
    toggleZoom = {{ 'alt', 'cmd' }, 'f' },
    upleft = {{ 'alt', 'cmd' }, '1' },
    upright = {{ 'alt', 'cmd' }, '2' },
    botleft = {{ 'alt', 'cmd' }, '3' },
    botright = {{ 'alt', 'cmd' }, '4' }
  })
Alt = Option on Mac

To move a window to the center of the screen with Hammerspoon:

  hs.hotkey.bind({"cmd", "alt"}, "s", function()
    -- size focused window to middle third of display
      local win = hs.window.focusedWindow()
      local f = win:frame()
      local screen = win:screen()
      local max = screen:frame()

      f.x = max.x + (max.w / 3)
      f.y = max.y
      f.w = max.w / 3
      f.h = max.h
      win:setFrame(f)
    end)
To move a window to the next/previous screen (external display):

  -- move window to next screen
  -- bind hotkey
  hs.hotkey.bind({'alt', 'ctrl', 'cmd'}, ']', function()
    -- get the focused window
    local win = hs.window.focusedWindow()
    -- get the screen where the focused window is displayed, a.k.a. current screen
    local screen = win:screen()
    -- compute the unitRect of the focused window relative to the current screen
    -- and move the window to the next screen setting the same unitRect 
    win:move(win:frame():toUnitRect(screen:frame()), screen:next(), true, 0)
  end)

  -- move window to previous screen
  -- bind hotkey
  hs.hotkey.bind({'alt', 'ctrl', 'cmd'}, '[', function()
    -- get the focused window
    local win = hs.window.focusedWindow()
    -- get the screen where the focused window is displayed, a.k.a. current screen
    local screen = win:screen()
    -- compute the unitRect of the focused window relative to the current screen
    -- and move the window to the previous screen setting the same unitRect 
    win:move(win:frame():toUnitRect(screen:frame()), screen:previous(), true, 0)
  end)
I use left alt and left command together for one handed shortcuts.

I use Quicksilver to set triggers to open apps with left_alt + "key"

https://qsapp.com/

Re: Keyboard tricks from a macOS app dev

#83

I was hoping this was about lesser known macOS keyboard shortcuts. Alas. Apple has a pretty exhaustive list of so-called document shortcuts that I find particularly useful: https://support.apple.com/en-us/HT201236#text Ctrl+A and Ctrl+E in particular to jump to the beginning and end of a line are a pair that I use dozens of times per day. Same with Opt+Delete to delete the previous word. I use Opt+Left Arrow and Opt+…

Lots of those shortcuts are basically Emacs shortcuts. I’m always sad using gdocs on Linux that they don’t support the Emacs shortcuts.

Side note that these Emacs shortcuts also work on iOS pretty much everywhere (you even get it for free in completely custom text renderers, so long as you adopt the UITextInput protocol)

Re: Keyboard tricks from a macOS app dev

#84

This post and thread are terrific, and the day I learned common Emacs bindings work in most corners of macOS was momentous, but… Whenever advanced keyboard shortcuts are under discussion, I’m reminded of something I read, I think by Bruce Tognazzini, on an early Apple study of keyboard vs. mouse. They had set up the usual usability test—run through these common spreadsheet tasks or whatever—and compared skilled users…

I wonder in what conditions this is true for.

I can imagine that moving the mouse to open an app from the macOS dock is about the same speed as using the Cmd+Space or some shortcut.

I can't imagine using the mouse to go to the start/end of line is quicker than using an easy to reach keyboard shortcut to do so.

I'd also wonder about differences in general computing literacy/etc. between 1989 and now. -- I'm not sure "people new to the mouse" describes a meaningful subset of professional computer users these days.

Re: Keyboard tricks from a macOS app dev

#85

I recently purchased a MacBook, and while I'm thoroughly impressed with the hardware, I find the keyboard navigation in the desktop environment somewhat lacking in comparison to my previous experience. Having used Linux Pop OS for many years, I've grown accustomed to the intuitive and powerful tiling window manager and keyboard navigation shortcuts it offers. I'm struggling to find a comparable solution on the macOS…

I don’t really tile windows much. The main case where I do is with a bunch of terminal windows. Most of what I get out of a tiling window manager is full screen by default and easy keys to switch workspaces. On macOS the thing that drives me insane is that the many-finger swipe to switch desktops won’t focus the target window until the animation is totally done (like 0.7s after starting). I wish it works like cmd+tab…

Just a heads up — you can solve that one annoyance; there are terminal commands that will reduce that animation to instantaneous.

Re: Keyboard tricks from a macOS app dev

#86

Earlier quoted context omitted.

It's a sore-spot for sure. I've found that Rectangle[0] does a good enough job. [0] https://rectangleapp.com/

Does Rectangle has a shortcut to switch the focused window in a split screen?

Hammerspoon can do it for I have it in my config. I also have it so I can switch to open windows on the same Space (I can throw windows into a tiled view and jump around to them). It's extremely flexible if you are willing to play around with it.

Re: Keyboard tricks from a macOS app dev

#87

Earlier quoted context omitted.

Lots of those shortcuts are basically Emacs shortcuts. I’m always sad using gdocs on Linux that they don’t support the Emacs shortcuts.

Side note that these Emacs shortcuts also work on iOS pretty much everywhere (you even get it for free in completely custom text renderers, so long as you adopt the UITextInput protocol)

How are you using the modifier keys in iOS?

Re: Keyboard tricks from a macOS app dev

#88
Some very good utilities listed in the article!

FuzzyKey would be really awesome, it's indeed an issue to remember all the complex conditional rebinds (and even in which app you've made it)

Would be nice if you could have an easily accessible cheat sheet and also press any combo in an app and let it tell you where and how it was defined

Re: Keyboard tricks from a macOS app dev

#89

I was hoping this was about lesser known macOS keyboard shortcuts. Alas. Apple has a pretty exhaustive list of so-called document shortcuts that I find particularly useful: https://support.apple.com/en-us/HT201236#text Ctrl+A and Ctrl+E in particular to jump to the beginning and end of a line are a pair that I use dozens of times per day. Same with Opt+Delete to delete the previous word. I use Opt+Left Arrow and Opt+…

It's much better to rebind all of those to more ergonomic alternatives that match your other apps using the tools listed (eg, to similar cursor keys you use in a text editor), which is also useful for non Macs you use (where you could do the same rebunds), rather then learning yet another set of bad old combos

Re: Keyboard tricks from a macOS app dev

#90
post #42

I recently purchased a MacBook, and while I'm thoroughly impressed with the hardware, I find the keyboard navigation in the desktop environment somewhat lacking in comparison to my previous experience. Having used Linux Pop OS for many years, I've grown accustomed to the intuitive and powerful tiling window manager and keyboard navigation shortcuts it offers. I'm struggling to find a comparable solution on the macOS…

As a more general suggestion, macOS likely isn’t good at imitating what you previously had, try to understand the workflow they’re proposing, adapt and learn it, it generally gets second nature and pretty decent soon enough, getting to work the way you envision is not apple’s strong suit.

The better general suggestion is to find good tools to make your OS life more comfortable rather than admitting defeat right away and imitating the bad old stuck ways of the OS

(it's not Apple's strong suit, but there is an app for tha™)

Post reply on HN