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

Moving to next text field using ENTER key

New Here ,
Jan 22, 2020 Jan 22, 2020

Copy link to clipboard

Copied

Hello, I'm relatively new to JavaScript and any help is greatly appreciated.

I have a form with multiple columns that a user will be filling out. The columns need to be filled out top to bottom. I would like to use the ENTER key to move to the next field in the column. I am aware that the TAB key is the default choice of Adobe, but it is not a logical choice for the users that will be using this form. Currently I have been using the script below to move from the first text field to the second. Is there a way for me to apply this script to the enite column without having to place the script in each text field's Custom Keystroke script area? I am using Adobe Acrobat Pro 2017 Thanks.

 

if (event.commitKey === 2) {

getField("Plant Sample Row2").setFocus();

}

 

 

TOPICS
Acrobat SDK and JavaScript

Views

1.8K

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

Community Expert , Jan 22, 2020 Jan 22, 2020

Kind of. What you can do is put it in a doc-level function and then call it from each field, but you'll still have to specify the name of the next field as parameter. For example, the generic function would be:

 

function goToNext(fieldName) {

if (event.commitKey === 2) {

this.getField(fieldName).setFocus();

}

}

 

And then you call it like this:

goToNext("Plant Sample Row2");

Likes

Translate

Translate
Community Expert ,
Jan 22, 2020 Jan 22, 2020

Copy link to clipboard

Copied

Kind of. What you can do is put it in a doc-level function and then call it from each field, but you'll still have to specify the name of the next field as parameter. For example, the generic function would be:

 

function goToNext(fieldName) {

if (event.commitKey === 2) {

this.getField(fieldName).setFocus();

}

}

 

And then you call it like this:

goToNext("Plant Sample Row2");

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
New Here ,
Jan 22, 2020 Jan 22, 2020

Copy link to clipboard

Copied

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
Participant ,
Feb 26, 2020 Feb 26, 2020

Copy link to clipboard

Copied

Hi, try67.

Is there a way to simulate the tabkey (script) whent the name of the next field in unknown?

No matter where the cursor is, I would like the script to move to the next field, as if I was using the tab key

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
Community Expert ,
Feb 26, 2020 Feb 26, 2020

Copy link to clipboard

Copied

No.

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
Participant ,
Feb 29, 2020 Feb 29, 2020

Copy link to clipboard

Copied

i'm sad to read that 🙂

Thank you for your answer.

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
New Here ,
Sep 14, 2022 Sep 14, 2022

Copy link to clipboard

Copied

I'm using Adobe Acrobat Pro DC and would also like to make it where ENTER moves the user to the next field. Since this was posted 2 years ago I'm wondering if the functionality is easier now or if the mentioned fix of putting in a doc-level function is the only way. If it is the only way, where would I actually put that function? And when you say "specify the name of the next field as parameter" how is that done?

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
Community Expert ,
Sep 14, 2022 Sep 14, 2022

Copy link to clipboard

Copied

Nothing has changed since the last posts about this subject. You don't have to use a doc-level script, but it's a better idea to do so, especially if you want to use it for multiple fields.

Specifying the name of the field to go to is done by supplying it as the parameter for the goToNext function. See above.

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
New Here ,
Sep 14, 2022 Sep 14, 2022

Copy link to clipboard

Copied

Where is the doc-level script entered?

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
Community Expert ,
Sep 14, 2022 Sep 14, 2022

Copy link to clipboard

Copied

LATEST

Under Tools - JavaScript - Document JavaScripts.

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