diff --git a/src/video_output/window.c b/src/video_output/window.c
index 48cd109745e2c0032d9b5cc1c5497ebd13cb6d13..16ebf9ef5a2252b896dd5edddd66fc2bc3465f56 100644
--- a/src/video_output/window.c
+++ b/src/video_output/window.c
@@ -326,10 +326,7 @@ static void vout_display_window_MouseEvent(vout_window_t *window,
 static void vout_display_window_KeyboardEvent(vout_window_t *window,
                                               unsigned key)
 {
-    vout_display_window_t *state = window->owner.sys;
-    vout_thread_t *vout = state->vout;
-
-    var_SetInteger(vout, "key-pressed", key);
+    var_SetInteger(vlc_object_instance(window), "key-pressed", key);
 }
 
 static void vout_display_window_OutputEvent(vout_window_t *window,