MacOS – Shortcut to select next item in a list

keyboardmacosshortcut

On macOS, it is possible to select items such as checkboxes or even dropdown lists by pressing the spacebar when the item in question is highlighted (usually with a colored box around the item). The ability to highlight them (usually by default or by using the tab key) can be enabled with the Full Keyboard Access setting in System Preferences > Keyboard > Shortcuts (this feature can also be enabled by pressing ControlF7).

I went to this website and tried to check out all of the fonts, which is done by selecting the font from the dropdown list. I wanted to quickly cycle through all of the fonts. I tried using the down arrow key to select the next list item when the list was highlighted.

However, when you press the down arrow, the list "pops up"; you then need to press down and then press enter (or space) in order to select the next item. This effectively means that, to select the next item in the currently highlighted list, you need to perform three keyboard actions, which makes it extremely cumbersome to cycle through all of the items.

I tried pressing the down arrow key while holding shift, alt, command, control, etc. hoping one of those would be a secret shortcut to select the next list item without, but using these modifies did not change anything.

Is there a good shortcut to select the next list item?

Best Answer

If you look "closer" at the fonts/names in the dropdown list you'll find they are being handled by server:
"patorjk.com/software/taag/#p=display&f=Rectangles&t=Hello\ world!"

The option group's name (html) is "optgroup label="Featured FIGlet Fonts", one font e.g.:
<option value="Rectangles.flf">Rectangles</option>

Therefore I assume they are sent by/to script
<script type="text/javascript" src="./js/figlet.js"></script>

It is certainly possible to delve deep into JavaScript and trace whatever commands it takes to solve this.
Actually I "studied" this page, tried AppleScript with/and Karabiner, but the list's behaviour is so "nervous** " that in the end I settled for a pure Automator/AppleScript solution:

tell application "System Events" to tell process "Safari"
    if name of front window of application "Safari" is "Text to ASCII Art Generator (TAAG)" then
        key code 125 --down… 
        delay 0.1
        key code 125
        key code 36
    end if
end tell

Actually this "just-so-working" code presumes you have selected the list, then press the shortcut shortly, let go, press shortly, let go, ...
(** AS/Karabiner, via osascript, worked nicely & quickly – but only circled through fonts with same 1st letters … very irritating, possibly due to some settings in the js-script.)

Now if this particular page is really important to you, try this: open Automator, goto

File>New>Service / left window: Execute AppleScript / top lists L/R: No input / Safari (any browser).
Paste above code into window. Safe as "Fonts-down" (for "going up" replace "125" with "126").

Final step: open Sys-Press Keyboard Shortcuts Services (left) scroll-down to "Fonts-down", check and input your chosen shortcut (e.g.: Opt-D). It should now appear as (menu) Safari>Services>Fonts-down.
(Depending on your general settings you may have to ONCE "allow" this script in Sys-Prefs.)

Okay.
– This script will only work in the specified window (important)
– If you press too long (try it) fonts may be skipped
– Sadly you'll have to choose a multi-key combo in Sys-Prefs keyboard, like Opt-D (Opt-U for "up"?)
   (If you use Karabiner you may define a 1-key shortcut to call "Opt-D".)
– This page is difficult to handle as its displayed content is created server-side.

Related Question