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

"keydown" and "keyup" events not recognised in AI CS6

Guide ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

"keydown" and "keyup" events do not seem to be recognised in AI CS6.  The snippet below works fine in AI CS4.  It is just me or is this across the board?  What's the case in CC?  Is there a way around this?  Thanks in advance. 

 

var window1 = new Window("dialog");
    var ed1 = window1.add("edittext", undefined, "0");
    var change = function (e) {
        if (e.keyName == "Up") {ed1.text = Number(ed1.text)+1};
        if (e.keyName == "Down") {ed1.text = Number(ed1.text)-1};
    }
    ed1.addEventListener("keydown", function (e) {change(e)});
window1.show();

 

TOPICS
Scripting

Views

440

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 , Jan 27, 2021 Jan 27, 2021

I noticed that the Arrow keys and the Function keys don't work. All other keys work fine. I wonder if that has anything to do with the "Function" key that allows us to have two different set of function on the same key ie my Left Arrow and Home use the same key.

 

if using other keys works for you, you can try this. I'm using "comma" and "point" keys instead of "up" and "down"

// https://community.adobe.com/t5/illustrator/quot-keydown-quot-and-quot-keyup-quot-events-not-recognised-in-ai-cs6/m-p/
...

Votes

Translate

Translate
Adobe
Valorous Hero ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Try on "keypress" ? 

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
Guide ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Thanks.  I tried "keypress".  I didn't work in either CS6 or CS4.

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
Community Expert ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Please contact Customer Care: http://helpx.adobe.com/contact.html They can login to your system.

Maybe they can help. 

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
Community Expert ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Hi @chanaart 

I don't think that Customer Care will be helpful in Illustrator Scripting questions. Sorry

 

@femkeblanco 

Please try the following (I haven't CS6 for testing):

var window1 = new Window("dialog");
    var ed1 = window1.add("edittext", undefined, "0");
    ed1.active = true;
    var change = function (e) {
        if (e.keyName == "Up") {ed1.text = Number(ed1.text)+1};
        if (e.keyName == "Down") {ed1.text = Number(ed1.text)-1};
    }
    ed1.addEventListener("keydown", function (e) {change(e)});
window1.show();

 

If that works for you

have fun

😉

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
Guide ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Thanks.  I tired that too.  But no luck.

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
Community Expert ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Strange.

Works for me in all newer versions.

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
Community Expert ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

same here it's not working on CS6, but it does work on CC2021

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
Community Expert ,
Jan 27, 2021 Jan 27, 2021

Copy link to clipboard

Copied

I noticed that the Arrow keys and the Function keys don't work. All other keys work fine. I wonder if that has anything to do with the "Function" key that allows us to have two different set of function on the same key ie my Left Arrow and Home use the same key.

 

if using other keys works for you, you can try this. I'm using "comma" and "point" keys instead of "up" and "down"

// https://community.adobe.com/t5/illustrator/quot-keydown-quot-and-quot-keyup-quot-events-not-recognised-in-ai-cs6/m-p/11785169?page=1#M261383
// "keydown", "keyup" event don't work on CS6

var w = new Window ("dialog"),
ed = w.add ("edittext", undefined, 0),
oldText = Number(ed.text);

ed.characters = 6;
ed.active = true;
ed.onChanging = function(){changed()};

w.show();

function changed() {
     if (ed.text.match(/,/) != null){
         ed.text = oldText + 1;
         oldText = Number(ed.text);
         return;
     }
      if (ed.text.match(/\./) != null){
         ed.text = oldText - 1;
         oldText = Number(ed.text);
         return;
     }
     oldText = Number(ed.text);
}

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
Guide ,
Jan 28, 2021 Jan 28, 2021

Copy link to clipboard

Copied

LATEST

In the cold light of day, the arrow keys not working isn't that big of a deal to me.  However, your solution is ingenious.  Thank you.  

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