[HN Gopher] Keyboard tricks from a macOS app dev
___________________________________________________________________
Keyboard tricks from a macOS app dev
Author : imaq
Score : 107 points
Date : 2023-04-23 17:19 UTC (5 hours ago)
(HTM) web link (notes.alinpanaitiu.com)
(TXT) w3m dump (notes.alinpanaitiu.com)
| kitsunesoba wrote:
| The blog post mentions text expansion via Raycast, but macOS has
| had its own native text expansion for a long time now (I think
| maybe since 10.5? Would need to check) under System
| (Preferences|Settings) > Keyboard > Text Replacements, which
| comes with the added bonus of syncing to your other Macs and
| iDevices via iCloud. I've been using it for years and at least
| for my needs it works great.
|
| Not mentioned are the text navigation shortcuts that have been
| built into macOS for a similarly long period of time. They work
| in any text field in nearly every app (with exception to a few
| oddball apps that are usually built with "game engine style" UI
| frameworks), and come in both control-based emacs style and Apple
| style flavors[0]. I use these constantly and they work
| exceptionally well for smaller keyboards (e.g. 60% or HHKB).
|
| [0]: https://jblevins.org/log/kbd
| alin23 wrote:
| Author here, I use the native macOS replacements as well,
| mostly because they sync with iOS and they save me a lot of
| typing on iPhone and iPad.
|
| But Raycast works differently in that: - it
| has dynamic replacements (see the video where I use ,td to type
| today's date for example) - can place cursor somewhere
| inside the replacement - makes it easy to add new
| snippets (Cmd-S on copied text) - is a lot faster in
| general and can work inside words as well
| gumby wrote:
| > I use ,td to type today's date
|
| That single feature alone is worth the app to me.
| mxstbr wrote:
| I built something similar myself with Karabiner Elements:
| https://www.youtube.com/watch?v=j4b_uQX3Vu0
|
| TL;DR: Capslock is Hyper key when held (Escape when pressed).
| Then I have hyperkey sublayers to allow for having essentially
| infinite commands: Capslock + O ("Open") + S ("Slack"), Capslock
| + S ("System") + U = Volume Up, J = Volume Down, etc.
| twoodfin wrote:
| 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 exclusively on mouse with
| equally skilled users issuing keyboard commands via shortcut.
| Maybe they swapped them back and forth on the modes, I don't
| recall.
|
| When the experiment was over, the mouse and keyboard users
| agreed: Shortcuts were faster, switching hands to the mouse and
| issuing commands via the cursor was slower. But the actual
| measured results showed no significant difference. Tog speculated
| that there's some deep perceptual circuitry that's tuned to
| notice the cost of mode-switching but submerge into the
| subconscious the cost of recall.
| pledg wrote:
| apps you can install which allow keyboard tricks, rather than
| macOS native.
| owlbite wrote:
| Just finding the app native ones can be useful, I spent several
| years using macOs before someone told me about apple-spacebar
| bringing up a spotlight quick search, which is not the main way
| I launch things that aren't terminal commands.
| zamnos wrote:
| spotlight also does simple math! so convenient.
| [deleted]
| zamnos wrote:
| Contexts.app for a more traditional alt-tab.
| hoosieree wrote:
| These are impressive, but can they fix an app that intercepts
| MacOS's defaults and hijacks them with inferior versions?
|
| Specifically I am interested in fixes for Outlook, which
| overrides the default text editing cursor movement commands with
| its own shortcuts.
| gnicholas wrote:
| I used to have a clipboard manager that gave me access to my last
| X copied items, as well as a navigable list of snippets. A few
| years back, a MacOS update broke whatever tool I was using, and I
| ended up buying BetterTouchTool. BTT does give me my clipboard
| history, and it appears to be very powerful in general, but I
| can't figure out an easy way to replicate the navigable list of
| snippets.
|
| I do use the MacOS text expansion system for my name and a few
| other items, but what it lacks is (1) I cannot use hyperlinked
| text in the expanded snippet, and (2) it requires me to remember
| an incantation for each expansion (I want to be able to look at a
| list of items and pick the one I want.
|
| Does anyone know of a tool that can do this? I don't mind paying,
| but free is always appreciated!
| nntwozz wrote:
| This is the way: https://maccy.app
| gnicholas wrote:
| Looks sleek and very lightweight; where does it say how it
| handles snippets? Or is the 'pinned' functionality supposed
| to be used to get old items to hang around?
| nntwozz wrote:
| Yep, for now.
|
| https://github.com/p0deje/Maccy/issues/130
| gnicholas wrote:
| OK thanks. Funny, the commenter in that thread came from
| the same software as me -- ClipMenu. It was simple and
| worked great!
| n8henrie wrote:
| I've used Quicksilver for clipboard history historically. There
| is a currently a bug that I've been meaning to delve into:
| https://github.com/quicksilver/Quicksilver/issues/2913 but
| still generally usable. Particularly handy combined with adding
| simple AppleScript or JXA actions to manipulate the content (I
| have several simple ones for example to run a regex, to clean
| extraneous content around a number, a phone number, strip
| whitespace, indent 4 spaces for pasting into a markdown
| codeblock on SO, etc etc).
|
| The Shelf plug-in also very handy along similar lines.
| bithaze wrote:
| FastScripts[1] might be worth a look. I've been meaning to
| check it out myself though so I can't offer any personal
| experience with it.
|
| [1] https://redsweater.com/fastscripts/
| themadsens wrote:
| Alfred (https://alfredapp.com) has a snippet manager (and a
| _whole_ lot more kbd goodies)
| [deleted]
| theshrike79 wrote:
| Alfred has a clipboard history among a billion other things
| alin23 wrote:
| Raycast's snippets mentioned in the article can do exactly
| that, screenshot here: https://shots.panaitiu.com/GmT5v4Zj
|
| It can do the incantation thingie, but it also allows binding a
| hotkey to showing a list of your snippets, searching through
| them, and inserting them with Enter.
|
| It can also do hyperlinks, bold, italic, if the app you're
| typing into supports rich text. Example:
| https://shots.panaitiu.com/gw50Zdcm
| gnicholas wrote:
| Thanks, I was just checking it out based on the article
| mention. Looks like it's free for personal use, too!
|
| EDIT: Looks like for snippets, it requires a key command to
| get Raycast to appear, then you have to say Search Snippets,
| then you have to type your search string, then you have to
| select the desired snippet. Is it really this many steps? My
| old workflow was shift-cmd-v, choose the desired snippet via
| arrow keys, hit return. With muscle memory, this ended up
| taking less than 4 seconds for most snippets.
| alin23 wrote:
| Nope, you can do it in a single step. You can record a
| hotkey for any action that Raycast has, you don't need to
| go to the main UI: https://shots.panaitiu.com/y6cGQTLN
|
| I rarely if ever see that main search UI, I have hotkeys
| for all my favorite workflows.
| gnicholas wrote:
| Dope, thanks!
| mechanicum wrote:
| If you can't get that working, Alfred[1] is a similar app
| with Snippets functionality including rich text, dynamic
| replacements, and is configurable to bring up the search by
| hotkey.
|
| [1]: https://www.alfredapp.com
| zamnos wrote:
| In this vein, I've got a Hammerspoon script so I can hit cmd-
| option-ctrl N, to make a new desktop with a fresh chrome window
| in it.
| darkteflon wrote:
| Big fan and long-time user of rcmd, Hyperkey, Rectangle, BTT -
| all lovingly-crafted by independent developers. All solo, I
| believe.
|
| I know Raycast is getting a lot of attention right now but isn't
| this a VC-backed SaaS? How do people feel about inviting them on
| to their desktop - aren't you worried about the inevitable other
| shoe dropping?
| n8henrie wrote:
| I've been happy using a combination of Karabiner, Hammerspoon,
| Quicksilver, and Espanso for these types of tasks for many years.
|
| Although the only thing I really need Karabiner for is remapping
| caps lock to a custom-defined "hyper" key (something odd
| combination of right and left shift, alt, command, etc) that
| everything else can use.
| darkteflon wrote:
| This might be the place to ask, since half an hour of searching
| the other day came up empty for Apple Silicon Macs: does anyone
| know how to diagnose hotkey conflicts? I use hyper (caps) + q, e
| to navigate between spaces but hyper + q recently stopped
| working, so ... I can only go right.
| sgt wrote:
| TIL about https://folivora.ai/ (BetterTouchTool). Brilliant.. and
| it's so refreshing to see an app that I will own and won't be a
| subscription. I can't stand that.
| jsmeaton wrote:
| One of the best things I've configured with BTT is to remove the
| global Quit application (cmd+Q) and global Hide application
| (cmd+H) keybindings. I use cmd+W all the time to shut tabs and a
| slight miss click would close the entire app.
| Okkef wrote:
| Ah this is from the creator of the 'rcmd' tool. I absolutely love
| it. Press the right command key + the first letter of an app and
| it switches right to it! (rcmd + for firefox, i for iTerm, s for
| Slack, ...)
|
| I came from i3 with 8 predefined windows, but the simplicity of
| rcmd is really amazing.
| httpteapot wrote:
| 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 platform.
| taspeotis wrote:
| Yeah I find some of the shortcuts confusing, like if I want to
| enter a directory in Finder I push ENTER and that's ... rename?
| Instead I'm meant to push PLACE OF INTEREST SIGN + O
| Trufa wrote:
| 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.
| httpteapot wrote:
| Do you know some good ressources to learn how to use macOS
| the productive way, using mostly keyboard shortcuts instead
| of the trackpad?
| dan-robertson wrote:
| 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 which changes focus instantly.
| Apart from that I guess I'm not that bothered because I mostly
| just full screen things. Emacs and iterm2 can do their own
| tiling of windows.
| illiarian wrote:
| Divvy for window management (assign your own shortcut).
|
| For almost everything else there's a standardized system-wide
| shortcut (including the ancient ones like Ctrl+a/e for text).
|
| If there isn't a shortcut, but the app exposes the action in a
| menu, you can assign a custom shortcut from keyboard settings.
|
| MacOS has traditionally been _very_ friendly to keyboard
| navigation. Well, until somewhat recently when mobile-only
| /mobile-first devs started just slapping Catalyst on and
| calling it a day. Even Apple's own apps suffer from this.
| richbell wrote:
| It's a sore-spot for sure. I've found that Rectangle[0] does a
| good enough job.
|
| [0] https://rectangleapp.com/
| httpteapot wrote:
| Does Rectangle has a shortcut to switch the focused window in
| a split screen?
| wtvanhest wrote:
| I've kind of solved this. You can snap windows but you need
| to add a shortcut in systems to do it. It's not perfect,
| but it does work and overtime you miss it less and less
| walthamstow wrote:
| No but Amethyst does
|
| https://github.com/ianyh/Amethyst
| jen729w wrote:
| I'll just throw Magnet in the ring for a tiling solution.
|
| I have keyboard shortcuts well in muscle memory now for
| left/right third/half/two-thirds, and all four corners at a
| quarter of screen, and full screen. I find that meets 90% of my
| needs.
|
| Left/right two-thirds is my go-to when coding on 14". VSCode on
| the left, Safari on the right. Both big enough to work well,
| but both leave enough of the other visible to be useful.
|
| Nice little app, costs some reasonable amount of money as a
| one-off purchase.
| orf wrote:
| I use Magnet, but settings not syncing across devices is a
| bit annoying.
| alin23 wrote:
| You can mimic that in part with yabai
| (https://github.com/koekeishiya/yabai). Disabling SIP gets you
| instant Space switching and creating without animation just
| like Pop_OS.
|
| But you can get very far to an automated tiling WM and keyboard
| navigation even without disabling SIP.
| bartvk wrote:
| Just because this often comes up; I don't want to disable
| SIP. However I'm very happy with yabai.
| foxandmouse wrote:
| I didn't realize it was possible to use it without
| disabling SIP, excited to give it another shot! AltTab with
| a few modifications is currently my preferred way to manage
| windows.
| bartvk wrote:
| To be honest I always wrote off Yabai until someone here
| commented that it works fine without disabling SIP. Only
| a small subset of features need that.
| userbinator wrote:
| I suspect the constant emphasis on mouse use, ever since the
| first Macintosh, has created an attitude of "keyboard doesn't
| matter"; I've noticed that even early Windows is very usable
| with only a keyboard (the Alt, underlined letters, and arrow
| keys method is particularly well-designed), whereas e.g.
| classic MacOS is basically unusable without a mouse.
|
| In later versions they added keyboard access, but it still
| feels like it was done as a bare-minimum concession and not
| originally planned.
| troyvit wrote:
| I had the opposite experience with MacOS. I hold every OS
| I've used since the early aughts up against MacOS 9 and they
| are all lacking in terms of keyboard navigation. Maybe it was
| because I had the previous 10 years to practice, but I felt I
| could do almost anything in pre-OSX MacOS with the keyboard,
| only relying on the mouse for application-specific stuff like
| photo editing. Navigating, filtering, opening files and
| folders were all incredibly easy.
|
| In KDE it's pretty much a joke every time I have to save-as.
| Can't even get through that filesystem menu without a mouse
| unless it supports <ctrl>-l. Dolphin is slightly better,
| especially if you enable the console pane to make it easier
| to switch to the command line, but it's still way behind
| Apple's finder from 1999.
| weaksauce wrote:
| > has created an attitude of "keyboard doesn't matter";
|
| I think you would be surprised at just how powerful the
| keyboard subsystem in osx is and how malleable it is with
| some programs or even just editing the plist shortcuts. every
| menu item in any application can be given a per app or
| universal shortcut in `system preferences | keyboard |
| shortcuts | app shortcuts`
|
| You can also use a thing like hammerspoon to do whatever you
| can imagine basically too... i have a few things for window
| manipulations via hammerspoon.
|
| You can set up very complex keyboard re-mappings/shortcuts
| using something like karabiner elements.
|
| you can also change the keyboard access to be navigable via
| tab in keyboard settings too.
|
| and you can access the menu via ctrl-f2 by default. those
| settings are changeable too via the keyboard preference pane.
|
| i think you'd be surprised at how much apple cares about
| accessibility so keyboard nav is not just a power user thing.
|
| At the end of the day I think apple put a lot of thought into
| the UI and i'd feel pretty stymied going back to
| windows.(though now the power utilities _finally_ let you
| remap the windows key to something more useful like ctrl.
| eitland wrote:
| My observation too.
|
| It is kind of evolution, just for computers.
|
| Macs early developed good pointing devices and as a result
| many keyboard related aspects can afford to be somewhere
| between weird and crazy.
|
| Bonus for Mac people insisting everything is fine.
|
| And I still consider getting a MacBook Pro next month,
| Windows PCs are that bad even with WSL :-/
|
| Edit: at least these days, fn and ctrl can finally be
| remapped and CMD-tab can be fixed so it works consistently
| between two Firefox (or two Safari) windows, an IDE and
| Finder. It used to be that I would have to CMD-tab to the
| Firefox group, then CMD-| to get to the correct browser
| window and it was one of the things that truly messed up my
| workdays the last time I used Mac back in 2012. (No dedicated
| home/end buttons and every app seemingly being free to choose
| what shortcut they would use for it was probably the most
| painful one though.)
| aaronbrethorst wrote:
| 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+Right Arrow to move the cursor back
| and forward by whole words so often that I didn't even think
| about including it in here until I unconsciously used it while
| editing text.
|
| Also:
|
| Cmd+Space brings up Spotlight and is a great way to launch apps
| and open documents.
|
| I've used SizeUp for well over a decade to rearrange my Mac's
| open windows. It's literally the first app I install when I get a
| new computer. https://www.irradiatedsoftware.com/sizeup/
| dan-robertson wrote:
| Lots of those shortcuts are basically Emacs shortcuts. I'm
| always sad using gdocs on Linux that they don't support the
| Emacs shortcuts.
| colechristensen wrote:
| Not just Emacs, but anything that uses readline or similar
| libraries. Most shells for example.
|
| https://en.wikipedia.org/wiki/GNU_Readline
|
| https://github.com/chzyer/readline/blob/master/doc/shortcut..
| ..
| m3kw9 wrote:
| BTT is great man, it just allows you to configure any shortcut
| for any app.
|
| But the one key I use the most is assigning "`" key as the back
| button. You keep your hand on that key while surfing web or any
| app that has a back navigation, it's just so much better than
| clicking or remembering each apps back shortcut.
|
| If you really need to type ` then you assign fn-` it's really
| rarely used
| mistersys wrote:
| My man must not write JS
| mcbain wrote:
| Or shell, or ruby, or markdown, or even just use Slack.
|
| Sure there are generally (sometimes better) alternatives in
| those but backticks are pretty common for me.
| m3kw9 wrote:
| Yep i knew there was a language that goes there too often
| dlivingston wrote:
| FYI, the keyboard shortcut for back is [?]+[, and forward is
| [?]+]. This is system-wide, and works in apps like Safari,
| Finder, Chrome, System Settings, etc.
| nbzso wrote:
| Better Touch Tool changed the way that I operate. Sequencing of
| keys can make you a productive monster:) Practically speaking, I
| remove the use of short keys that require to break my fingers
| every day.
| jack_riminton wrote:
| Yeah my most recent discovery is using GPT4 to create
| applescripts which are triggered by a key combination. One that
| I use all the time is to open a chrome window with a specific
| profile to certain webpages
| ryangittins wrote:
| Yes! I'm sure I'm not using it anywhere close to its full
| potential, but just being able to two-finger tap a link to open
| it in a new tab is huge.
|
| What are your favorite shortcuts?
___________________________________________________________________
(page generated 2023-04-23 23:00 UTC)