sebseb
sebseb

Reputation: 93

What's the hot key for TAB in .lua? hammerspoon?

I would like to do an ALT + TAB after the COPY:

hs.eventtap.keyStroke({"cmd"}, "C")

In this code SOURCE by user: @user3439894

So, normally it would be something like this, as suggested by @Oka:

hs.eventtap.keyStroke({"alt"}, "tab")

and this:

hs.eventtap.keyStroke({"alt"}, {"tab"})

But this doesn't work. Or probably I'm placing it in the wrong place.

And I don't know how to use this suggestions, by Oka:

pushkeycode(L, kVK_Tab, "tab");

SOLVED by @user3439894 in this other post

Upvotes: 1

Views: 1466

Answers (1)

Oka
Oka

Reputation: 26365

In this issue, the correct string to use is said to be "tab".

After some digging around in the keycodes extension source code, we can confirm this.

From keycodes.lua:

--- hs.keycodes.map
--- Constant
--- A mapping from string representation of a key to its keycode, and vice versa.
--- For example: keycodes[1] == "s", and keycodes["s"] == 1, and so on.
--- This is primarily used by the hs.eventtap and hs.hotkey extensions.
---
--- Valid strings are any single-character string, or any of the following strings:
---
---     f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15,
---     f16, f17, f18, f19, f20, pad., pad*, pad+, pad/, pad-, pad=,
---     pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7, pad8, pad9,
---     padclear, padenter, return, tab, space, delete, escape, help,
---     home, pageup, forwarddelete, end, pagedown, left, right, down, up,
---     shift, rightshift, cmd, rightcmd, alt, rightalt, ctrl, rightctrl,
---     capslock, fn

We can see this set up in the keycodes_cachemap function in libkeycodes.m:

pushkeycode(L, kVK_Tab, "tab");

Upvotes: 2

Related Questions