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

can i connect keystrokes directly to functions?

Enthusiast ,
Oct 02, 2022 Oct 02, 2022

Copy link to clipboard

Copied

Hi Experts, i wonder if i can connect keystrokes directly to functions instead of double click or (run) the script everytime with UI , i mean can i run script once and call the functions via keystrokes instead of showing Script UI that need to be Active to respond? and thanks in advance

#targetengine "mysession";
var w = new Window("palette", {independent:true});
w.orientation = "stack"
w.alignment = "center"

var edit = w.add ("edittext")
edit.visible = false
edit.active = true;

w.text = "Send KeyStrokes to Execute Functions"
w.preferredSize.width = 200;
w.alignChildren = ["left", "top"]; 
w.orientation = "row"; 
w.spacing = 5;
w.margins = 16
w.add ("statictext", undefined,"Send KeyStrokes to Execute Functions");

w.show();

w.addEventListener ("keydown", function keyPressed(key){
    switch (key.keyName) {
        case "U":
        PressU();
        case "V":
        PressV();
        case "H":
        PressH();
        case "M":
        PressM();
        case "Escape":
        w.close()
    }
})

 

Best
Mohammad Hasanin
TOPICS
Scripting

Views

142

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

Community Expert , Oct 03, 2022 Oct 03, 2022

If I understand you correctly, no, you can't. It looks as if you're simply trying to program your own keyboard shortcut handler. There's no need, InDesign has one. Store your functions as individual scripts and assign shortcut keys to them in InDesign's keyboard shortcuts editor.

Votes

Translate

Translate
Community Expert ,
Oct 03, 2022 Oct 03, 2022

Copy link to clipboard

Copied

If I understand you correctly, no, you can't. It looks as if you're simply trying to program your own keyboard shortcut handler. There's no need, InDesign has one. Store your functions as individual scripts and assign shortcut keys to them in InDesign's keyboard shortcuts editor.

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
Enthusiast ,
Oct 03, 2022 Oct 03, 2022

Copy link to clipboard

Copied

LATEST

@Peter Kahrel Thanks a lot, maybe this feature will be added in the future!

Best
Mohammad Hasanin

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