Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map scancode to KeyCode #10977

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Map scancode to KeyCode #10977

wants to merge 1 commit into from

Conversation

estin
Copy link
Contributor

@estin estin commented Jun 17, 2024

Hi! It's an optional solution to use a keyboard scancode.

Based on the comment: #165 (comment)

And on: #10228
 
Introduced the new feature scancode to enable the following logic:

  • on command  and jump-to-word modes query keyboard pressed scancode  via keyboard_query
  • map scancode to key and build a new KeyEvent and pass it back.

It isn't required to change user keymap configurations.
 

cargo install --features scancode --locked --path helix-term
  Config
[editor.scancode]
layout = "qwerty" # from pre-configured defaults
# layout = "myconfig"  # user defined config

# user personal config
[editor.scancode.map]

# [scancode, [key, shifted key]]
myconfig = [
  [1, ["esc"]],
  [2, ["1", "!"]],
  [3, ["2", "@"]],
  [4, ["3", "#"]],
  [5, ['4', '$']],
  [6, ['5', '%']],
  [7, ['6', '^']],
  [8, ['7', '&']],
  [9, ['8', '*']],
  [10, ['9', '(']],
  [11, ['0', ')']],
  [12, ["-", "_"]],
  [13, ['=', "+"]],
]
  

And it works well on my setup (linux/x11 and qwerty keyboard).

I tried to implement it in a separate module and simplify the API as an optional helix feature.

Such an approach as the compilation flag for "desktop" Helix users is the right way?

  

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Jun 21, 2024
@estin estin marked this pull request as ready for review June 23, 2024 11:38
@estin estin force-pushed the scancode branch 2 times, most recently from c371b45 to 4c40b05 Compare July 22, 2024 06:24
@estin estin force-pushed the scancode branch 3 times, most recently from 4345daa to 070a337 Compare July 29, 2024 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants