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

Enthusiast ,
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

166

Likes

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

Adobe Community Professional , 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/...

Likes

Translate

Translate
Adobe Community Professional ,
Jan 26, 2021 Jan 26, 2021

Copy link to clipboard

Copied

Try on "keypress" ? 

Likes

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

Copy link to clipboard

Copied

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

Likes

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
Adobe Community Professional ,
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. 

Likes

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
Adobe Community Professional ,
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

😉

Likes

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

Copy link to clipboard

Copied

Thanks.  I tired that too.  But no luck.

Likes

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

Copy link to clipboard

Copied

Strange.

Works for me in all newer versions.

Likes

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
Adobe Community Professional ,
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

Likes

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
Adobe Community Professional ,
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);
}

Likes

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 ,
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.  

Likes

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