Jump to content

How to use keyboard hotkey to replace non actionable keyboard shortcut in Notion


Recommended Posts

Hi all,

 

Fabrice/poirpom here. I live in France*. This my is first post in this forum.

 

*Therefore my ability to write or understand english is far from perfection. Apologize my mistakes.

 

To provide a little bit of context :

  • Happy powerpack Alfred user from more than 3 years, I enjoy using it every single day (29.7 times a day on average according to the usage stats provided, up to 150 on a single day).
  • Although I have no knowledge at all in scripting, I find ways to achieve very helpful stuff with Alfred every day, thanks to the basic but powerful tools provided to create workflows.
  • Another piece of software/SaaS I use a lot is Notion. Combining Alfred and a wonderful web browser extension called Save to notion, I've been able to add content to a notion database thanks to a single workflow

 

Enough with the context.

 

Regarding Notion, I'm trying to solve a "localized problem" :

  • Notion provides a keyboard shortcut to show/hide the sidebar ⌘+\
  • Unfortunately, this shortcut doesn't work on a french keyboard. Because the character \ is done with the combination ⌥ + ⇧ + /
  • I thought I could find a find to emulate the required combination (⌘+\) by : 
    • activating a workflow with a hotkey of my choice (only when Notion has focus)
    • setting an argument ⌘\ (I've tried with both options – pass through input argument selected and not selected)
    • using a key combo output with the override with input argument selected

 

Obviously, nothing happens. But I don't even know if what I'm trying to achieve can be done with Alfred, if I'm on the right path or completely wrong (that won't be the first time).

 

Any piece of advice would be really appreciated.

 

Thanks in advance.

 

CleanShot 2021-04-27 at 15.18.23.png

Link to comment
1 hour ago, giovanni said:

welcome to the forum!

Have you tried to launch a simple applescript like this below? 


tell application "Notion" to activate
tell application "System Events" to key code 42 using command down

 

Hi giovanni

 

Thanks for your answer and the welcome.

 

I tried what you just said (see screenshots, just to be sure I did it right).

 

What happens in Notion when I use my hotkey : it types the character ` (counter tick, if i'm correct).

 

Is there something I'm doing wrong ? Sorry, I'm completely new to scripts and not sure at all.

CleanShot 2021-04-27 at 19.05.28.png

CleanShot 2021-04-27 at 19.05.08.png

CleanShot 2021-04-27 at 19.06.22.gif

Link to comment
1 minute ago, poirpom said:

Is there something I'm doing wrong ? Sorry, I'm completely new to scripts and not sure at all.

 

Maybe it has soemthing to do with the key codes being different on a french azerty keyboard ?

Link to comment

I tried this (on a US keyboard) and it works from Script Editor and from Terminal via ```osascript``` but NOT from Alfred. I tried with an osascript(AS) run script object  (as recommended) and running via bash script but neither worked ... perhaps some additional permissions are needed? Can you try and see if you have the same problem by saving those 2 lines as an applescript using the script editor and see if that works? 

Link to comment
1 hour ago, poirpom said:

Maybe it has soemthing to do with the key codes being different on a french azerty keyboard ?

 

It does. A key code maps to a physical key, not the character it produces. Key code 42 is always the lower key next to ↩.

 

Try tell application "System Events" to keystroke "\\" using command down


If that doesn’t work, tell application "System Events" to key code 47 using command down should simulate the correct physical key if I tried the right French keyboard layout (where . is on an QWERTY keyboard).

 

If that doesn't work, you should ask Notion.

Edited by deanishe
Link to comment

@giovanni & @deanishe

 

Thank you both for your detailed answers.

 

Unfortunately, none of those solutions worked. Even through the script editor (and I checked : it has accessibility permissions.)

 

It's weird because I tried with a different key code (44 → = sign on a french keyboard) to emulate the zoom in (with ⌘) and it worked.

 

I've been able to solve other keyboard shorcuts issues I had with Keysmith, but as this ability (hiding the side bar) in notion appears only on hover, keysmith isn't able to solve it (I've been in contact with them to try to figure it out)

 

So it seems you are right, deanishe. I should ask notion to see if there's a work around.

 

Thank you again for taking the time to answer me

Link to comment
8 minutes ago, poirpom said:

It's weird because I tried with a different key code (44 → = sign on a french keyboard) to emulate the zoom in (with ⌘) and it worked.

 

I’m pretty sure the problem is the extra modifier key () you need to press to get \ on your keyboard.


The app isn’t expecting it because Notion didn't consider that some keyboard don’t have a key for \.

Link to comment
13 minutes ago, deanishe said:

 

I’m pretty sure the problem is the extra modifier key () you need to press to get \ on your keyboard.


The app isn’t expecting it because Notion didn't consider that some keyboard don’t have a key for \.

 

I agree. 

 

2 minutes ago, giovanni said:

@poirpomthe hover issue should not matter, because I was able to hide the sidebar running the applescript from script editor and terminal.

Would remapping the actual key (with Karabiner or similar) be a solution here? 

 

You're right. I'll have a try with karabiner to see if I can find a way around

 

Regarding keysmith, hover is an issue, as keysmith emulates actual clicks on your screen (placing your mouse cursor where it has to click) but isn't able to emulate a mouse move, therefore the button to hide the sidebar doesn't appear.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...