# ScriptCommandData.func.qualifiers always "none" when combined with @keydown

**URL:** <https://resource.dopus.com/t/scriptcommanddata-func-qualifiers-always-none-when-combined-with-keydown/52301>\
**Category:** Help & Support\
**Tags:** script, bug-report\
**Created:** [August 15, 2024, 2:51pm UTC](https://resource.dopus.com/t/scriptcommanddata-func-qualifiers-always-none-when-combined-with-keydown/52301 "2024-08-15T14:51:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![svArt](https://resource.dopus.com/user_avatar/resource.dopus.com/svart/32/12646_2.png) [@svArt](https://resource.dopus.com/u/svArt)\
**Post date:** [August 15, 2024, 2:51pm UTC](https://resource.dopus.com/t/scriptcommanddata-func-qualifiers-always-none-when-combined-with-keydown/52301/1 "2024-08-15T14:51:44Z")

</div>

I just ran into an issue where I don't get qualifier keys reported in `ScriptCommandData.func.qualifiers` when the button script calls the user command from a `@keydown` modifier conditional.  
In fact, when there is _any_ `@keydown` modifier present in the button script

Command MYCOMMAND:

```auto
function OnInit(initData){
	initData.name = "Test Command";
	initData.version = "0.1.0";

	var cmd = initData.AddCommand();
	cmd.name = "MYCOMMAND";
	cmd.method = "OnCmd";
	cmd.label = "MYCOMMAND";
	cmd.template = "STR";
}

function OnCmd(data){
	DOpus.Output(data.func.args.STR + " <--> " + data.func.qualifiers);
}

```

Button script:

```auto
@keydown:ctrl
MYCOMMAND ctrl
@keydown:none
MYCOMMAND none
@keydown:shift
MYCOMMAND shift
@keydown:any
MYCOMMAND any

```

Always gives "none":

> 2024-08-15 16:39 Test Command: none \<--\> none  
> 2024-08-15 16:39 Test Command: ctrl \<--\> none  
> 2024-08-15 16:39 Test Command: any \<--\> none  
> 2024-08-15 16:39 Test Command: shift \<--\> none  
> 2024-08-15 16:39 Test Command: any \<--\> none  
> 2024-08-15 16:39 Test Command: any \<--\> none

Only when there is no `@keydown` modifier in the script will the script get the qualifiers:

```auto
MYCOMMAND NoModifier

```

Gives

> 2024-08-15 16:45 Test Command: NoModifier \<--\> none  
> 2024-08-15 16:45 Test Command: NoModifier \<--\> ctrl  
> 2024-08-15 16:45 Test Command: NoModifier \<--\> shift  
> 2024-08-15 16:45 Test Command: NoModifier \<--\> alt  
> 2024-08-15 16:45 Test Command: NoModifier \<--\> shift,ctrl  
> 2024-08-15 16:45 Test Command: NoModifier \<--\> shift,alt  
> 2024-08-15 16:45 Test Command: NoModifier \<--\> ctrl,alt  
> 2024-08-15 16:45 Test Command: NoModifier \<--\> shift,ctrl,alt

Note that even keydowns below will break it:

```auto
MYCOMMAND NoModifierButStillBroken
@keydown:ctrl
MYCOMMAND ctrl

```

> 2024-08-15 16:50 Test Command: NoModifierButStillBroken \<--\> none  
> 2024-08-15 16:50 Test Command: ctrl \<--\> none

☹  
What's up with that?

is this still a thing/related? [User command and @keydown : bug? - #4 by Leo](https://resource.dopus.com/t/user-command-and-keydown-bug/4354/4)

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [August 15, 2024, 3:00pm UTC](https://resource.dopus.com/t/scriptcommanddata-func-qualifiers-always-none-when-combined-with-keydown/52301/2 "2024-08-15T15:00:15Z")

</div>

That is by design, to allow you to assign commands to hotkeys without the hotkey choice affecting what the command does when the command itself looks at which keys are down.

Passing arguments to the command to tell it what you want it to for each call would make the most sense here. (Or not using @keydown at all and having all the key logic in the command. Basically, it should only be in one place or the other, not two places both interpreting which keys are down and hoping things are consistent between them.)

Scripts can also use DOpus.GetQualifiers to get the "real" key state, but remember that it may not match the key state at the time the button was clicked, if the key is released between the click and when the method is called.

---

<div class="post-metadata">

**Author:** ![svArt](https://resource.dopus.com/user_avatar/resource.dopus.com/svart/32/12646_2.png) [@svArt](https://resource.dopus.com/u/svArt)\
**Post date:** [August 15, 2024, 3:12pm UTC](https://resource.dopus.com/t/scriptcommanddata-func-qualifiers-always-none-when-combined-with-keydown/52301/3 "2024-08-15T15:12:31Z")

</div>

Grrr, that's unfortunate.  
As you may have guessed, the above command was just an example to illustrate the issue 😛  
Actual commands in question are already defined and I don't want to rewrite the templates, lest I run into trouble with some calling script that I forgot to adapt or something; also it doesn't fit the concept 😕  
I guess I'll use GetQualifiers first thing when the command executes.

It would be nice to have the ability to choose to pass the qualifiers through. Maybe give the gremlins among us who would prefer to live dangerously in their own chaos of "hoping things are consistent" an advanced setting to toggle that behavior on or off?  
Or a new modifier like `@keepqualifiers` to prepend to a button command?

---

<div class="post-metadata">

**Author:** ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)\
**Post date:** [August 16, 2024, 2:15am UTC](https://resource.dopus.com/t/scriptcommanddata-func-qualifiers-always-none-when-combined-with-keydown/52301/4 "2024-08-16T02:15:18Z")

</div>

We'll add `Func.qualifiers_raw` in 13.9.6 which will return the true as opposed to filtered qualifiers.

---

<div class="post-metadata">

**Author:** ![svArt](https://resource.dopus.com/user_avatar/resource.dopus.com/svart/32/12646_2.png) [@svArt](https://resource.dopus.com/u/svArt)\
**Post date:** [August 16, 2024, 3:44pm UTC](https://resource.dopus.com/t/scriptcommanddata-func-qualifiers-always-none-when-combined-with-keydown/52301/5 "2024-08-16T15:44:31Z")

</div>

Wow, thank you!! 🥳 ❤
