# Check modifier keys during drag & drop

**URL:** <https://discourse.glfw.org/t/check-modifier-keys-during-drag-drop/1564>\
**Category:** support\
**Created:** [May 19, 2020, 3:21pm UTC](https://discourse.glfw.org/t/check-modifier-keys-during-drag-drop/1564 "2020-05-19T15:21:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![franz](https://avatars.discourse-cdn.com/v4/letter/f/c37758/32.png) [@franz](https://discourse.glfw.org/u/franz)\
**Post date:** [May 19, 2020, 3:21pm UTC](https://discourse.glfw.org/t/check-modifier-keys-during-drag-drop/1564/1 "2020-05-19T15:21:05Z")

</div>

Hi,

Is it possible to check that the left or right Shift key is pressed when dragging a file onto a GLFW window?

I’ve tried the following but unsurprisingly it didn’t work (because Shift wasn’t pressed in the GLFW window):

```auto
const bool shift_pressed =
    glfwGetKey(get_window(), GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS ||
    glfwGetKey(get_window(), GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS;

```

I suspect that the answer is that what I’m asking isn’t possible, but I hope to be wrong!

Thanks for a great library.

---

<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 19, 2020, 4:36pm UTC](https://discourse.glfw.org/t/check-modifier-keys-during-drag-drop/1564/2 "2020-05-19T16:36:46Z")

</div>

Try setting the window focus with `glfwFocusWindow(window);` in your drop callback, then checking the state. I just did a quick test and this seemed to work for me.

---

<div class="post-metadata">

**Author:** ![franz](https://avatars.discourse-cdn.com/v4/letter/f/c37758/32.png) [@franz](https://discourse.glfw.org/u/franz)\
**Post date:** [May 19, 2020, 5:06pm UTC](https://discourse.glfw.org/t/check-modifier-keys-during-drag-drop/1564/3 "2020-05-19T17:06:46Z")

</div>

What works is the following workflow:

1. GLFW window is in focus.
2. User presses Shift, then drags & drops a file onto the window.

In this case, `shift_pressed` is `true`, even without adding

```auto
glfwFocusWindow(window);

```

What _doesn’t_ work sadly is this:

1. User switches focus to another window (typically, Windows Explorer).
2. User drags & drops file onto GLFW window (which isn’t in focus).

In this case, `shift_pressed` is `false`, even with the `glfwFocusWindow()` call.

I think the only way that latter workflow can work is by checking the keyboard status _at the time of the file drop_ (and not relying on the key cache).
