How to Create Function Keys From F1 to F20 on Touch Bar When Pressing fn Key?

I want to be able to access function keys from F1 to F20, displayed on touchbar of MacBook Pro when pressing fn key. I was trying to use bettertouchtool to achieve this, but failed. My post on BTT forum was left unanswered. Is there a way to do it with KBM or a combination of KBM and BBT?

I think normally there are only 12 F-keys visible on the Touch bar. If you want 20, you have to change the size of the self-made BTT buttons. Then you assign any actions to the buttons, which are only visible when you press fn.

I don't know If this can be done easier with KM.

Thanks, @Frankb. The issues is not how to create buttons in BTT - this is the easy part, but rather how to gain access to F13-20 programmatically.

What do those Fn keys do? Could you target the "do" programmatically rather than simulating the keypress?

If not, you might be able to AppleScript things:

tell application "System Events" to key code 105

...should be F13. The others are listed at but, for completeness:

F13: 105
F14: 107
F15: 113
F16: 106
F17: 64
F18: 79
F19: 80
F20: 90
1 Like

This is cool, @Nige_S - I'll try to play with these.

The only reason I want these keys is it expands my key combinations options for KBM.

Also do you know if there is a way to program Right Command and Right Option and Right Shift Keys differently from the left ones for the purposes of KBM recognition/shortcuts?

Since no one answers who knows more than I do.

As far as I know, KM can not distinguish between left and right modifiers. Whether it might work with Apple Scripts, I don't know. I don't think this has been asked before.

What I know for sure, BTT can distinguish very well between left and right, including all combinations. And fn can also be used as a modifier for shortcuts.

You'll have to remap the keys with something like Karabiner Elements -- plenty of mentions in the Forum.

Thank you for your advice!