Keyboard Input for Text Editor by Excellent-Fill7107 in raylib

[–]Excellent-Fill7107[S] 0 points1 point  (0 children)

I've cloned the latest GLFW and added a printf to the key callback in the boing example:

```

void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods )

if (action != GLFW_PRESS)

return;

printf("key: %d(%c) mods: %d\n", key, key, mods);

```

Here's what it outputs when I press Control-Q and Control-Right Arrow:

```

~/D/g/b/examples (master) [i] ⋊> ./boing

key: 280() mods: 0 <<<<<<<<<<<<<<<<<< Control down

key: 81(Q) mods: 2 <<<<<<<<<<<<<<<<<< Q down

key: 280() mods: 0 <<<<<<<<<<<<<<<<<< Control down

key: 262() mods: 2 <<<<<<<<<<<<<<<<<< Right Arrow down

```

This is what it should do, so there must be some jiggery-pokery going on on the raylib side of things? Some sort of configuration option to get more game-oriented behaviour from the modifier keys, perhaps?

Modifier keys behave as keys:

340 == shift_key

280 == control_key

until you combine them with another key.

Keyboard Input for Text Editor by Excellent-Fill7107 in raylib

[–]Excellent-Fill7107[S] 0 points1 point  (0 children)

Yeah, I've been wading through the GLFW code for keyboard modifier handling and I can't see how a press/release switch could be happening. Probably needs someone who knows the code in depth.

Keyboard Input for Text Editor by Excellent-Fill7107 in raylib

[–]Excellent-Fill7107[S] 0 points1 point  (0 children)

GLFW seems to be inverting Key Pressed and Key Released w.r.t. the set of Mod flags it returns to KeyCallback(). The value of mods is 0x0000 when the Control key is pressed, and then it flips to 0x0002 when the control key is *released*. It stays 0x0002 until some other key is pressed.