Userscript to type missing characters into Google Sheets on mac
This script was started when I wanted to type $ and other shift+option characters into Google Sheets on MacOS with a Danish keyboard.
The problem
It turns out that 7 out of the ten shift+option+digit keys available on the keyboard have been hijacked by Google Sheets for internal shortcuts to add and remove borders to cells. On many keyboard layouts thats not a problem, but for scandinavian keyboard layouts it means that these 7 characters: ¯ ” $ ¢ \ { , simply can not be type into Sheet, and instead must be copy-pasted to be inserted.
This is especially problematic if you type in formulas in Google Sheets, since several of these signs are vital in formulas.
The solusion
I've created a userscript that can be installed in Chrome and other browsers, which will intercept keyboard events on the Google Sheets page. If any of the 10 shift+option+digit keys are pressed, the event is blocked and the proper character is inserted via clipboard.
In Google Sheets, if a cell is in edit mode, a character is insertes exactly as if it was any ordinary key.
If the cell is not in edit mode, the behaviour is slightly different to if it was any ordinary key:
- An ordinary key event would insert the character into a cell, overwriting contents, and leave the cell in edit model, so subsequent key events would be added to the cell.
- This solusion will insert the character into the cell, overwriting contents, but NOT leave the cell in edit mode, so subsequent key events will overwrite contents.
Usage
Simply install the script in Tampermonkey, and reload your Google Sheets page.
Install Tampermonkey from here: https://www.tampermonkey.net/