Skip to content

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
@estin estin force-pushed the scancode branch 2 times, most recently from a598e8f to fb8f2e6 Compare December 18, 2024 06:15
@estin estin force-pushed the scancode branch 2 times, most recently from 76f939a to a9dade4 Compare January 6, 2025 09:56
@estin
Copy link
Contributor Author

estin commented Jan 23, 2025

New option - read scancode via evdev

cargo install --path helix-term  --features scancode-evdev --locked

And previous way via keyboard_query

cargo install --path helix-term  --features scancode-query --locked
feature crate linux (x11) linux (wayland) windows macos
scancode-evdev evdev yes yes no no
scancode-query keyboard_query yes no ? ?
scancode-hidapi hidapi yes yes no* ?
  • no not supported
  • yes works, tested
  • ? must works, not tested
  • * Access is denied for non-custom HID on windows

P.S. In plans try to read keyboard scancodes via libusb/hidapi

UPDATE

New variant to read keyboard events - use hidapi (on Linux /dev/hidrawX must be allowed to read)

cargo install --path helix-term  --features scancode-hidapi --locked

@estin estin force-pushed the scancode branch 2 times, most recently from 0c22c67 to 40f8b21 Compare January 31, 2025 06:21
@estin estin force-pushed the scancode branch 2 times, most recently from c82e288 to 7f730fa Compare March 4, 2025 17:28
@estin estin force-pushed the scancode branch 2 times, most recently from cce26a1 to 087ca38 Compare March 20, 2025 14:19
@estin estin force-pushed the scancode branch 2 times, most recently from 5f0ed5f to fe914a0 Compare March 28, 2025 07:01
@estin estin force-pushed the scancode branch 2 times, most recently from 06a8d67 to 4f47650 Compare June 25, 2025 06:09
@estin estin force-pushed the scancode branch 4 times, most recently from ccbfae6 to cd2bb25 Compare July 21, 2025 05:33
@partrita
Copy link

partrita commented Aug 8, 2025

I've been waiting for this for a long time. Fingers crossed!

@estin estin force-pushed the scancode branch 2 times, most recently from b1df7ca to 82a4d60 Compare August 17, 2025 12:54
@estin estin force-pushed the scancode branch 2 times, most recently from 1cbff52 to a0e3836 Compare September 1, 2025 14:06
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.

3 participants