sagemathinc / cocalc

CoCalc: Collaborative Calculation in the Cloud
https://CoCalc.com
Other
1.16k stars 211 forks source link

jupyter keyboard shortcuts -- change to use event.key instead of event.which #4020

Open williamstein opened 5 years ago

williamstein commented 5 years ago

This is purely an internal implementation detail, but it could fix some bugs, especially for non-US keyboards...

williamstein commented 1 month ago

No example and no info in 5 years. So closing.

williamstein commented 1 month ago

Actually, this is still a good idea.

williamstein commented 1 month ago

To do this:

  1. Open src/packages/frontend/jupyter/commands.ts
  2. Use this code:
    function f(keyCode) { chrCode = keyCode - 48 * Math.floor(keyCode / 48); return String.fromCharCode(96 <= keyCode ? chrCode : keyCode).toLowerCase();}
  3. Replace all which: number by key: f(number), probably via a bunch of separate and tedious uses of sed in the terminal?
  4. Change evt_to_obj to use e.key.toLowerCase() instead of e.which.
  5. Something may need to be changed in src/packages/frontend/jupyter/keyboard-shortcuts.tsx to account for this changes. There's a comment there.