Help defining a nonstandard key

I would like to add a key to the numpad layer that would signal : when pressed, without needing to press Shift like I would with the standard semicolon key.

Things I have tried (not with any expectation that they’d necessarily work, but in case they might have worked):

  • putting Key_Colon in the keymap (by analogy with the existing Key_Semicolon)
  • in key_defs_keyboard.h, copying the line #define Key_Semicolon (Key) { HID_KEYBOARD_SEMICOLON_AND_COLON, KEY_FLAGS } and editing the copy to #define Key_Colon (Key) { HID_KEYPAD_COLON, KEY_FLAGS } (but apparently there is no such HID definition)

What else would you suggest trying? Would it actually be easiest to use a macro that just returns :?

Here’s what you want: LSHIFT(Key_Semicolon)

1 Like

To elaborate: There are five macros that set bits in the flags byte of the Key object, which are used to add modifier keys to basic keyboard keycodes:

LSHIFT()
LCTRL()
LGUI()
LALT()
RALT()

These macros can be combined. For example, if you want a key that sends control+shift+S, you define a key like this in your keymap:

LCTRL(LSHIFT(Key_S))

…and if you want a key that combines three modifiers:

LCTRL(LSHIFT(Key_LeftAlt))

[Note: the reason both alt keys are included is because the two alt keys are frequently treated differently by software on the host (right alt is often AltGr).]

3 Likes

Neat! Thanks, that will be very useful for other things too.

Thank you for that information, I’ve been meaning to work out how to do ctrl-alt and ctrl-shift single keys in particular!

That said, the other options are to use Key_KeypadColon (found that and several other useful usually-shifted-unshifted numberpad keys from here) or of course using TopsyTurvy.