Assistance for complex modifier: assign Underscore ("_") character to F16 (USA layout)

178 views
Skip to first unread message

Ryan Noyes

unread,
Nov 5, 2020, 8:37:19 PM11/5/20
to Karabiner
Hello all,
Mr. Fumihiko, I can't thank you enough for developing this tool!  I am interested in building a complex modifier to trigger the Underscore via F16.  EventViewer says F16 is 107.  However, I am not sure how to get a code for the "_" character,  which is only accessed on a US keyboard layout by pressing Shift + "-" ("-" is the hyphen key).  EventViewer says Shift is 229 and hyphen ("-") is 45.  I basically need the character that the hyphen key generates while shift is held down.  I am very sorry that I do not know code!

Any guidance would be most greatly appreciated.  Thank you so much in advance!

My best,
Ryan


raf

unread,
Nov 6, 2020, 4:54:23 PM11/6/20
to Karabiner
Hi,

You can refer to keys by name. I think you want something like this:

{
"manipulators": [
{
"description": "Change F16 to underscore.",
"from": {
"key_code": "f16",
"modifiers": { "optional": [ "any" ] }
},
"to": [
{
"key_code": "hyphen",
"modifiers": [ "left_shift" ]
}
],
"type": "basic"
}
]
}

That's what I use (but to map capslock to underscore).
I have it in my ~/.config/karabiner/karabiner.json file
(in profiles[0]->complex_modifications->rules) but it's
probably better to put it in its own file inside
~/.config/karabiner/assets/complex_modifications but
I haven't tried that yet. If you want to put it there,
I'd suggest downloading a complex modification from
the internet just to see what its entire JSON structure
looks like, and matching it when creating your own rule.

cheers,
raf

raf

unread,
Nov 6, 2020, 10:37:42 PM11/6/20
to Karabiner
Hi again,

I've just migrated my complex modifications out of the
main ~/.config/karabiner/karabiner.json file into separate
files in the ~/.config/karabiner/assets/complex_modifications
directory.

Here's a version of the above that can be put into a file in
that directory
(e.g ~/.config/karabiner/assets/complex_modifications/change-f16-to-underscore.json).

{
"title": "Change F16 to underscore",
"rules":
[
{
"manipulators":
[
{
"description": "Change F16 to underscore",
"from": { "key_code": "f16", "modifiers": { "optional": [ "any" ] } },
"to": [ { "key_code": "hyphen", "modifiers": [ "left_shift" ] } ],
"type": "basic"
}
]
}
]
}

You would then need to activate it in Karabiner-Elements ->
Preferences -> Complex modifications -> Add rule, then
enable it in the dialog box that appears. Good luck.

cheers,
raf

Ryan Noyes

unread,
Nov 8, 2020, 11:59:14 AM11/8/20
to Karabiner
Works like a charm. This is extremely helpful. Thanks so much for walking me through this!

--
You received this message because you are subscribed to a topic in the Google Groups "Karabiner" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/osx-karabiner/EqybjyS6ju8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to osx-karabine...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osx-karabiner/20201107033737.7puaodrlnogwjrtk%40raf.org.

raf

unread,
Nov 8, 2020, 4:12:39 PM11/8/20
to Karabiner
On Sun, Nov 08, 2020 at 11:59:01AM -0500, Ryan Noyes <ryan.w...@gmail.com> wrote:

> On Fri, Nov 6, 2020 at 10:37 PM raf <kara...@raf.org> wrote:
>
> > On Sat, Nov 07, 2020 at 08:54:17AM +1100, raf <kara...@raf.org> wrote:
> >
> > > On Thu, Nov 05, 2020 at 05:37:18PM -0800, Ryan Noyes < ryan.w...@gmail.com> wrote:
> > >
> > > > Hello all,
> > > > Mr. Fumihiko, I can't thank you enough for developing this tool! I am
> > > > interested in building a complex modifier to trigger the Underscore via
> > > > F16. EventViewer says F16 is 107. However, I am not sure how to get a
> > > > code for the "_" character, which is only accessed on a US keyboard layout
> > > > by pressing Shift + "-" ("-" is the hyphen key). EventViewer says Shift is
> > > > 229 and hyphen ("-") is 45. I basically need the character that the hyphen
> > > > key generates while shift is held down. I am very sorry that I do not know
> > > > code!
> > > >
> > > > Any guidance would be most greatly appreciated. Thank you so much in
> > > > advance!
> > > >
> > > > My best,
> > > > Ryan
> > >
> > > [...]
> > >
> > Here's a version of the above that can be put into a file in
> > that directory
> > (e.g
> > ~/.config/karabiner/assets/complex_modifications/change-f16-to-underscore.json).
> >
> > {
> > "title": "Change F16 to underscore",
> > "rules":
> > [
> > {
> > "manipulators":
> > [
> > {
> > "description": "Change F16 to underscore",
> > "from": { "key_code": "f16", "modifiers": {
> > "optional": [ "any" ] } },
> > "to": [ { "key_code": "hyphen", "modifiers": [
> > "left_shift" ] } ],
> > "type": "basic"
> > }
> > ]
> > }
> > ]
> > }
> >
> > You would then need to activate it in Karabiner-Elements ->
> > Preferences -> Complex modifications -> Add rule, then
> > enable it in the dialog box that appears. Good luck.
>
> Works like a charm. This is extremely helpful. Thanks so much for walking
> me through this!

No worries. Glad to hear it's working.

cheers,
raf

Reply all
Reply to author
Forward
0 new messages