# Help defining a nonstandard key

**URL:** <https://community.keyboard.io/t/help-defining-a-nonstandard-key/1197>\
**Category:** Programming\
**Tags:** question\
**Created:** [March 6, 2018, 2:16am UTC](https://community.keyboard.io/t/help-defining-a-nonstandard-key/1197 "2018-03-06T02:16:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aedifica](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/aedifica/32/348_2.png) [@aedifica](https://community.keyboard.io/u/aedifica)\
**Post date:** [March 6, 2018, 2:16am UTC](https://community.keyboard.io/t/help-defining-a-nonstandard-key/1197/1 "2018-03-06T02:16:22Z")

</div>

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 `:`?

---

<div class="post-metadata">

**Author:** ![merlin](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/merlin/32/3416_2.png) [@merlin](https://community.keyboard.io/u/merlin)\
**Post date:** [March 6, 2018, 2:55am UTC](https://community.keyboard.io/t/help-defining-a-nonstandard-key/1197/2 "2018-03-06T02:55:41Z")

</div>

Here’s what you want: `LSHIFT(Key_Semicolon)`

---

<div class="post-metadata">

**Author:** ![merlin](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/merlin/32/3416_2.png) [@merlin](https://community.keyboard.io/u/merlin)\
**Post date:** [March 6, 2018, 3:05am UTC](https://community.keyboard.io/t/help-defining-a-nonstandard-key/1197/3 "2018-03-06T03:05:12Z")

</div>

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:

```auto
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:

```auto
LCTRL(LSHIFT(Key_S))

```

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

```auto
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`).]

---

<div class="post-metadata">

**Author:** ![aedifica](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/aedifica/32/348_2.png) [@aedifica](https://community.keyboard.io/u/aedifica)\
**Post date:** [March 6, 2018, 4:27am UTC](https://community.keyboard.io/t/help-defining-a-nonstandard-key/1197/4 "2018-03-06T04:27:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Llamalland](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/llamalland/32/832_2.png) [@Llamalland](https://community.keyboard.io/u/Llamalland)\
**Post date:** [April 29, 2018, 11:16am UTC](https://community.keyboard.io/t/help-defining-a-nonstandard-key/1197/5 "2018-04-29T11:16:28Z")

</div>

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](https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_keyboard.h)) or of course using TopsyTurvy.
