aboutsummaryrefslogtreecommitdiff
path: root/demo.c
diff options
context:
space:
mode:
Diffstat (limited to 'demo.c')
-rw-r--r--demo.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/demo.c b/demo.c
index 3b16fc2..4a5cb38 100644
--- a/demo.c
+++ b/demo.c
@@ -9,22 +9,35 @@ int main(int argc, char *argv[]) {
termkey_key key;
while((ret = termkey_waitkey(tk, &key)) != TERMKEY_RES_EOF) {
- if(key.flags & TERMKEY_KEYFLAG_SPECIAL)
+ switch(key.type) {
+ case TERMKEY_TYPE_KEYSYM:
printf("Key %s%s%s%s (code %d)\n",
key.modifiers & TERMKEY_KEYMOD_SHIFT ? "Shift-" : "",
key.modifiers & TERMKEY_KEYMOD_ALT ? "Alt-" : "",
key.modifiers & TERMKEY_KEYMOD_CTRL ? "Ctrl-" : "",
- termkey_get_keyname(tk, key.code),
- key.code);
- else
+ termkey_get_keyname(tk, key.code.sym),
+ key.code.sym);
+ break;
+ case TERMKEY_TYPE_FUNCTION:
+ printf("Function key %s%s%sF%d\n",
+ key.modifiers & TERMKEY_KEYMOD_SHIFT ? "Shift-" : "",
+ key.modifiers & TERMKEY_KEYMOD_ALT ? "Alt-" : "",
+ key.modifiers & TERMKEY_KEYMOD_CTRL ? "Ctrl-" : "",
+ key.code.number);
+ break;
+ case TERMKEY_TYPE_UNICODE:
printf("Unicode %s%s%s%s (U+%04X)\n",
key.modifiers & TERMKEY_KEYMOD_SHIFT ? "Shift-" : "",
key.modifiers & TERMKEY_KEYMOD_ALT ? "Alt-" : "",
key.modifiers & TERMKEY_KEYMOD_CTRL ? "Ctrl-" : "",
key.utf8,
- key.code);
+ key.code.codepoint);
+ break;
+ }
- if(key.modifiers & TERMKEY_KEYMOD_CTRL && (key.code == 'C' || key.code == 'c'))
+ if(key.type == TERMKEY_TYPE_UNICODE &&
+ key.modifiers & TERMKEY_KEYMOD_CTRL &&
+ (key.code.codepoint == 'C' || key.code.codepoint == 'c'))
break;
}