cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Is there a way to create a keyboard shortcut so that a user can create a new row in a repeating section but not have to click on "Add New Row"?

I am creating a form with a repeating section in which the users may have to add up to 30 or so rows.  One of the users requested a keyboard shortcut for adding a row without having to click on "Add a Row" to speed up input.  Is this possible?

Thank you!

0 Kudos
Reply
1 Reply
Workflow Hero

Re: Is there a way to create a keyboard shortcut so that a user can create a new row in a repeating section but not have to click on "Add New Row"?

You could use something similar to the following code in the Custom JavaScript section of the form settings.

 

document.onkeyup = function(e) {
     if (e.ctrlKey && e.altKey && e.shiftKey && e.which == 13) {
          NWF$("a.ms-addnew").click();
     }
};

I pulled line 3 from Marian Hatala‌'s response on this question:

"Want to add a new row to a Nintex forms Repeating section through JavaScript method  scenario: I hav...‌"

I removed the .RSClass reference for my example, but it would come in handy if you have multiple repeating sections on one form. Keep in mind, you would need to add this class name to your repeating section control before it would work.

Line's 1 & 2 are what catch the key press. In this example, I set it to work when you press Ctrl + Alt + Shift + Enter, but of course you could choose any number of keys for your shortcut. This is simply to show you how to use multiple keys, and that some keys can be referenced by a system name, while others require a number. Simply Google 'keymap javascript' or use a site like JavaScript Event KeyCodes to determine the number code for the key of your choice.

If you have any trouble with this.....it can get more complicated.

.onkeyup is just one of three options you could use. The other two being .onkeydown and .onkeypress

.onkeyup fires when you release the key, whereas .onkeydown will fire when you press the key down and this can fire continually if you hold the key. .onkeypress acts similarly to .onkeydown in my testing.

Additionally, I've seen .key, .code, and .keyCode used in place of .which. I read online that there may be a difference among browsers. You'll just have to try it out. 

I'm sure that's more than you care to know, but hopefully it's helpful to you and others.




SharePoint 2013 On-Prem | Nintex Forms & Workflow Enterprise
Accept as Solution Reply