# Linux, X11: Enter key not seen at Char callback

**URL:** <https://discourse.glfw.org/t/linux-x11-enter-key-not-seen-at-char-callback/1117>\
**Category:** support\
**Created:** [May 10, 2018, 6:20pm UTC](https://discourse.glfw.org/t/linux-x11-enter-key-not-seen-at-char-callback/1117 "2018-05-10T18:20:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheako](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/cheako/32/189_2.png) [@cheako](https://discourse.glfw.org/u/cheako)\
**Post date:** [May 10, 2018, 6:20pm UTC](https://discourse.glfw.org/t/linux-x11-enter-key-not-seen-at-char-callback/1117/1 "2018-05-10T18:20:43Z")

</div>

I added code in the Key callback to emit an event for Char 10, looks like this:

> <https://github.com/cheako/cheako-vulkan/blob/47778b6d6feff551e4f746df66ac6a122d2e20c7/013editor/libdata.c#L27-L29>

  
However this does not support key repeat.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 11, 2018, 9:14am UTC](https://discourse.glfw.org/t/linux-x11-enter-key-not-seen-at-char-callback/1117/2 "2018-05-11T09:14:18Z")

</div>

I’m not sure if you looking for help with [dear imgui](https://github.com/ocornut/imgui) or with [GLFW](http://www.glfw.org/)?

The enter key is already handled by imgui’s widgets, see the demo multi-line text input widget for an example.

In GLFW the enter key is not sent to the char callback. I think it could be argued that it should be (perhaps optionally), as a text file can include return characters. However at the moment the intention is that you should handle GLFW\_KEY\_ENTER yourself via the key callbacks or glfwGetKey().

if you need to implement repeat then you need to add code to do this. For an example see [https://github.com/glfw/glfw/blob/master/src/input.c#L260-L279](https://github.com/glfw/glfw/blob/master/src/input.c#L260-L279)

---

<div class="post-metadata">

**Author:** ![cheako](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/cheako/32/189_2.png) [@cheako](https://discourse.glfw.org/u/cheako)\
**Post date:** [July 1, 2018, 7:39pm UTC](https://discourse.glfw.org/t/linux-x11-enter-key-not-seen-at-char-callback/1117/3 "2018-07-01T19:39:57Z")

</div>

That code is a horrible example.

1. It doesn’t implement key repeat it detects key repeat in the key callback, from what I understand that is a bug in the glfw driver.
2. The repeated variable can be removed by moving the test a few lines down. So it’s not ideal for anyone to copy that code.

---

<div class="post-metadata">

**Author:** ![cheako](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/cheako/32/189_2.png) [@cheako](https://discourse.glfw.org/u/cheako)\
**Post date:** [July 1, 2018, 7:43pm UTC](https://discourse.glfw.org/t/linux-x11-enter-key-not-seen-at-char-callback/1117/4 "2018-07-01T19:43:27Z")

</div>

Implementing key repeat in the key callback is a bad idea for a number of reasons most importantly configuration. We don’t wanna present the user with an interface that has a different key repeat delay or rate for the enter key.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [July 2, 2018, 10:15am UTC](https://discourse.glfw.org/t/linux-x11-enter-key-not-seen-at-char-callback/1117/5 "2018-07-02T10:15:42Z")

</div>

As I mentioned earlier I think there’s a case for passing the return through to the char callback. If you’d like to request this the relevant place is the [GLFW issue tracker](https://github.com/glfw/glfw/issues) and I’d be happy to post an issue if you don’t have a Github account. Currently the codepoints for carriage return and line feed are filtered out by [https://github.com/glfw/glfw/blob/master/src/input.c#L292](https://github.com/glfw/glfw/blob/master/src/input.c#L292)

Re the ‘example’:

1. It was a bad section of code for me to link to without explanation, as it’s not an example of how to implement what you desire but shows how the GLFW code detects key repeats. I should instead have explained more about GLFW\_REPEAT.
2. The test can’t be moved further down without further logic as when stickyKeys is set the action stored in the key table needs to be GLFW\_PRESS and not GLFW\_REPEAT.

If you implement this yourself you don’t have to worry about getting the wrong repeat interval, as the key events are sent at the rate as char events (key events are translated into char events by OS specific functions). So if you can handle GLFW\_REPEAT in your key callback in the same way as GLFW\_PRESS you should get the same result as if it was handled by glfwInputChar.
