12

This question specifically applies to Google Documents, not Google Spreadsheets (but if the answer applies to both, all the better).

Google Documents has built-in Keyboard shortcuts for Google Docs. I would like to define my own key binding or shortcut so that I can run a user-defined script on the document directly without using the mouse. For scripts that I want to run often, having a key binding or shortcut I can press saves me wasted motion from having to use the mouse to pull down a menu and run the script.

I have scoured the Google Apps Script APIs and found no mention of allowing this level of customization.

Do I conclude that Google did not include this feature?

I have not investigated possibilities of using Firefox-specific extensions but that would be my next approach (e.g., Greasemonkey).

Note that this is not the same question as asked in How can I create custom keyboard shortcuts in Google Docs?.

0
5

There is no built-in functionality for this: see How to create custom keyboard shortcuts for google app script functions?

Instead, you could use a script that triggers a menu option when a key combination is pressed would be the thing to try. This has more to do with scripting your browser (clicking certain page elements on a particular site), so for details I refer to SuperUser, in particular to Is it possible to set keyboard shortcuts on a webpage?

1

There is a workaround that has worked for me in Google Sheets. If you choose the option to create a Macro in the "Tools" menu, you will be prompted to create a name and a keyboard shortcut for your Macro. When you do, Google Apps Script will automatically add a tab in your script editor file called Macro. You can now paste any script coding of your choice into that newly created function, and your keyboard shortcut will call it.

Note: the keyboard shortcuts for this functionality are limited to Ctrl + Shift + Alt + a number of your choosing. A bit complicated of a shortcut key combo, but at least is it a keyboard shortcut.

2
  • @serenesat, have you tried this 'workaround? I ask because when I tried it I couldn't even do the first step, and I wonder if it even refers to Google Documents. The original post says, "This question specifically applies to Google Documents, not Google Spreadsheets". Could you please provide some images showing the steps described here? In Google Documents, of course. Thanks – Tony M May 23 '20 at 15:45
  • @TonyM I have not tried. – serenesat May 23 '20 at 20:01
1

From the question

Do I conclude that Google did not include this feature?

As of June 25th, 2020 this feature is not available for Google Documents, only for Google Sheets.

Google Sheets has a macro recorder that includes a way to assign a keyboard shortcut to fire a macro and a way to import existing scripts as macros. See Google Sheets Macros

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.