• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Multiple keys on a keyboard EventListener

Participant ,
Dec 15, 2016 Dec 15, 2016

Copy link to clipboard

Copied

Is it possible to do something like this? So if Cmd + O are pressed, it gets triggered?

TOPICS
Actions and scripting

Views

836

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Dec 15, 2016 Dec 15, 2016

Nevermind, figured it out:

dlg.addEventListener ("keydown", function (k) {keyListen(k)});

function keyListen(k){

    if(ScriptUI.environment.keyboardState.metaKey && k.keyName == "O"){

        // do something

        return;

    }

}

It works, but for some reason my Mac emits the alert sound as soon as it's finished. Anyone know why?

Votes

Translate

Translate
Adobe
Participant ,
Dec 15, 2016 Dec 15, 2016

Copy link to clipboard

Copied

LATEST

Nevermind, figured it out:

dlg.addEventListener ("keydown", function (k) {keyListen(k)});

function keyListen(k){

    if(ScriptUI.environment.keyboardState.metaKey && k.keyName == "O"){

        // do something

        return;

    }

}

It works, but for some reason my Mac emits the alert sound as soon as it's finished. Anyone know why?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines