# Gtk, get coordinates of keypress

**URL:** <https://discourse.julialang.org/t/gtk-get-coordinates-of-keypress/9923>\
**Category:** Visualization\
**Created:** [March 23, 2018, 3:53pm UTC](https://discourse.julialang.org/t/gtk-get-coordinates-of-keypress/9923 "2018-03-23T15:53:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kurt\_Franke](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@Kurt\_Franke](https://discourse.julialang.org/u/Kurt_Franke)\
**Post date:** [March 23, 2018, 3:53pm UTC](https://discourse.julialang.org/t/gtk-get-coordinates-of-keypress/9923/1 "2018-03-23T15:53:09Z")

</div>

Hi, I’m trying to get a keypress to do something based on the mouse coordinate in a GtkCanvas widget. I can receive the keypress in the main GtkWindow, and I’d like to translate the coordinates with the library call gtk\_widget\_translate\_coordinates( ), but it doesn’t look like this is exposed in the Gtk package. Is there another way to do this?

Edit: I didn’t realize that the keypress event doesn’t even have mouse coordinates associated with it, so I am on the wrong track… I want to get the coordinates of the mouse in the GtkCanvas when I press a certain key.

Julia version 0.6.1  
Gtk version 0.13.1  
Thanks you,  
Kurt

---

<div class="post-metadata">

**Author:** ![Kurt\_Franke](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@Kurt\_Franke](https://discourse.julialang.org/u/Kurt_Franke)\
**Post date:** [March 23, 2018, 4:53pm UTC](https://discourse.julialang.org/t/gtk-get-coordinates-of-keypress/9923/2 "2018-03-23T16:53:01Z")

</div>

I decided to use the mouse motion signal continuously to keep track of the last mouse coordinates, and then use those when a key is pressed…
