koekeishiya / skhd

Simple hotkey daemon for macOS
MIT License
6.05k stars 204 forks source link

How can I insert a UTF-8 character with skhd? #285

Open danijar opened 1 year ago

danijar commented 1 year ago

I came across skhd -k "return" by googling but skhd -k "ü"doesn't work. Is there another flag for that?

toftstade commented 1 year ago

As far as I can tell skhd doesn't work well with chars outside of a-z; I ended up using Ukulele for remapping of keys instead.

tjex commented 1 year ago

As far as I can tell skhd doesn't work well with chars outside of a-z; I ended up using Ukulele for remapping of keys instead.

type skhd -o in a terminal, this will observe keypresses and return the hex code for that key. This can then be used in skhd for remaps.

In terms of OP problem, it may be a better approach to look at how your terminal emulator handles accented characters. If you're on mac, it relates to a keyboard feature introduced by apple called the 'compose key' which basically enables access to the unicode characters under letters / symbols when holding alt.

This normally needs to be enabled in the term emulator itself.

eg in wezterm there is an option:

config.send_composed_key_when_left_alt_is_pressed = true
config.send_composed_key_when_right_alt_is_pressed = true
PrimeTimeTran commented 2 months ago

@tjex Where would we remap? I'm having trouble mapping my Hyperkey + b. It works great for hyperkey + h j k l but not b for some reason.

tjex commented 2 months ago

what do you mean "where would we remap", it's in the skhdrc.

But sounds like you're already mapping hotkeys. Maybe you're double mapping hyper + b?

Pls post / point to your config file. Otherwise the possibilities are endless.

PrimeTimeTran commented 2 months ago

@tjex thanks for getting back to me. Sorry for being unclear. Inside of my .config/skhd/skhdrc I have this.

shift + alt + ctrl + cmd - b : skhd -k "shift + 3"

I'd like for it to insert one # into whatever app I have open(Obsidian, Zed, VSCode, etc).

Even better would be if I could get it to insert two # so that it's a ##.

Thanks in advance~!

PrimeTimeTran commented 2 months ago

Wow, just reread the readme and found it.

shift + alt + ctrl + cmd - b : skhd -t "##"

Regardless thanks~! =)

tjex commented 2 months ago

Not a prob :)