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\"?"

  • 2 August 2018
  • 2 replies
  • 9 views

Badge

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!


2 replies

Badge +7

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

218200_pastedImage_16.png 

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 have a db that have a products. when user search for a product in a nintex form textbox it will call the web api through javscript and display those results i‌"

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.

Badge +1

If you have flexibility (like, if you can program a barcode reader to prepend or append an arbitrary string), you can use the following 5 keystrokes "<tab> <tab> <Enter> <shift>-<tab> <shift>-<tab>".  (Not sure what keycode a <shift>-<tab> combined character is, but if you can send it from the keyboard, you can probably program it into a macro on a keyboard or a barcode reader.

 

Hope that helps someone!

Reply