summaryrefslogtreecommitdiff
path: root/docs/feature_macros.md
diff options
context:
space:
mode:
authorKonstantin Đorđević <vomindoraan@gmail.com>2020-06-20 22:58:48 +0200
committerGitHub <noreply@github.com>2020-06-20 21:58:48 +0100
commit02781979d6af096e8adb6bb02af7639b73c8f267 (patch)
tree14f645abe369041c7d869d93d9aa6ec4d926325c /docs/feature_macros.md
parent69b484600f672ef9b1368c121512d579f9b7fc98 (diff)
[Docs] Improve Unicode documentation (#8676)
Diffstat (limited to 'docs/feature_macros.md')
-rw-r--r--docs/feature_macros.md89
1 files changed, 46 insertions, 43 deletions
diff --git a/docs/feature_macros.md b/docs/feature_macros.md
index 1c7705a516..acd40d1bf3 100644
--- a/docs/feature_macros.md
+++ b/docs/feature_macros.md
@@ -6,34 +6,34 @@ Macros allow you to send multiple keystrokes when pressing just one key. QMK has
## The New Way: `SEND_STRING()` & `process_record_user`
-Sometimes you just want a key to type out words or phrases. For the most common situations we've provided `SEND_STRING()`, which will type out your string (i.e. a sequence of characters) for you. All ASCII characters that are easily translated to a keycode are supported (e.g. `\n\t`).
+Sometimes you want a key to type out words or phrases. For the most common situations, we've provided `SEND_STRING()`, which will type out a string (i.e. a sequence of characters) for you. All ASCII characters that are easily translatable to a keycode are supported (e.g. `qmk 123\n\t`).
Here is an example `keymap.c` for a two-key keyboard:
```c
enum custom_keycodes {
- QMKBEST = SAFE_RANGE,
+ QMKBEST = SAFE_RANGE,
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- switch (keycode) {
+ switch (keycode) {
case QMKBEST:
- if (record->event.pressed) {
- // when keycode QMKBEST is pressed
- SEND_STRING("QMK is the best thing ever!");
- } else {
- // when keycode QMKBEST is released
- }
- break;
-
- }
- return true;
+ if (record->event.pressed) {
+ // when keycode QMKBEST is pressed
+ SEND_STRING("QMK is the best thing ever!");
+ } else {
+ // when keycode QMKBEST is released
+ }
+ break;
+ }
+ return true;
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- [0] = {
- {QMKBEST, KC_ESC}
- }
+ [0] = {
+ {QMKBEST, KC_ESC},
+ // ...
+ },
};
```
@@ -49,42 +49,45 @@ You can do that by adding another keycode and adding another case to the switch
```c
enum custom_keycodes {
- QMKBEST = SAFE_RANGE,
- QMKURL,
- MY_OTHER_MACRO
+ QMKBEST = SAFE_RANGE,
+ QMKURL,
+ MY_OTHER_MACRO,
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- switch (keycode) {
+ switch (keycode) {
case QMKBEST:
- if (record->event.pressed) {
- // when keycode QMKBEST is pressed
- SEND_STRING("QMK is the best thing ever!");
- } else {
- // when keycode QMKBEST is released
- }
- break;
+ if (record->event.pressed) {
+ // when keycode QMKBEST is pressed
+ SEND_STRING("QMK is the best thing ever!");
+ } else {
+ // when keycode QMKBEST is released
+ }
+ break;
+
case QMKURL:
- if (record->event.pressed) {
- // when keycode QMKURL is pressed
- SEND_STRING("https://qmk.fm/\n");
- } else {
- // when keycode QMKURL is released
- }
- break;
+ if (record->event.pressed) {
+ // when keycode QMKURL is pressed
+ SEND_STRING("https://qmk.fm/\n");
+ } else {
+ // when keycode QMKURL is released
+ }
+ break;
+
case MY_OTHER_MACRO:
- if (record->event.pressed) {
- SEND_STRING(SS_LCTL("ac")); // selects all and copies
- }
- break;
- }
- return true;
+ if (record->event.pressed) {
+ SEND_STRING(SS_LCTL("ac")); // selects all and copies
+ }
+ break;
+ }
+ return true;
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- [0] = {
- {MY_CUSTOM_MACRO, MY_OTHER_MACRO}
- }
+ [0] = {
+ {MY_CUSTOM_MACRO, MY_OTHER_MACRO},
+ // ...
+ },
};
```