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

Backslash key and Cmd+key input not working on MacOS with Japanese Macbook #2530

Closed
Lokechu opened this issue May 8, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@Lokechu
Copy link

Lokechu commented May 8, 2024

I am unable to input a backslash character and also unable to copy/paste using keyboard shortcuts such as Cmd+c/Cmd+v while using a Japanese MacBook.

To Reproduce
Steps to reproduce the behavior:

  1. Open Neovide
  2. Try to type backslash character while in input mode by holding option and pressing the ¥ key.
  3. Instead of \ character being printed to the buffer, it switches from input to normal mode as if ESC had been pressed.

Expected behavior
\ character should be printed to the buffer

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: macOS 14.4.1
  • Neovide Version: 0.12.2
  • Neovim Version: 0.10.0-dev-3050+gcb24a3907

TRACE [neovide::channel_utils] neovim_handler WindowViewport { grid: 2, top_line: 0.0, bottom_line: 2.0, current_line: 0.0, current_column: 0.0, line_count: Some(1.0), scroll_delta: Some(0.0) }
TRACE [neovide::channel_utils] neovim_handler Flush
TRACE [neovide::editor] Image flushed
TRACE [neovide::editor] send_batch
TRACE [neovide::renderer::rendered_window] Handling Viewport 2
TRACE [neovide::renderer::fonts::caching_shaper] Shaping text: "INSERT"
TRACE [neovide::window::keyboard_manager] KeyEvent {
physical_key: Code(
KeyI,
),
logical_key: Character(
"i",
),
text: None,
location: Standard,
state: Released,
repeat: false,
platform_specific: KeyEventExtra {
text_with_all_modifiers: Some(
"i",
),
key_without_modifiers: Character(
"i",
),
},
}
TRACE [neovide::window::keyboard_manager] KeyEvent {
physical_key: Code(
AltLeft,
),
logical_key: Named(
Alt,
),
text: None,
location: Left,
state: Pressed,
repeat: false,
platform_specific: KeyEventExtra {
text_with_all_modifiers: None,
key_without_modifiers: Named(
Alt,
),
},
}
TRACE [neovide::window::keyboard_manager] Modifiers { state: ModifiersState(ALT), pressed_mods: ModifiersKeys(LALT) }
TRACE [neovide::window::keyboard_manager] KeyEvent {
physical_key: Code(
IntlYen,
),
logical_key: Character(
"\",
),
text: Some(
"\",
),
location: Standard,
state: Pressed,
repeat: false,
platform_specific: KeyEventExtra {
text_with_all_modifiers: Some(
"\",
),
key_without_modifiers: Character(
"¥",
),
},
}
TRACE [neovide::window::keyboard_manager] Key pressed <M-¥> ModifiersState(ALT)
TRACE [neovide::channel_utils] UICommand Serial(Keyboard("<M-¥>"))
TRACE [neovide::bridge::ui_commands] In Serial Command
TRACE [neovide::bridge::ui_commands] Keyboard Input Sent: <M-¥>
TRACE [neovide::bridge::handler] Neovim notification: "redraw"
TRACE [neovide::channel_utils] neovim_handler GridLine { grid: 4, row: 0, column_start: 95, cells: [GridLineCell { text: "\", highlight_id: Some(1426), repeat: None }] }
TRACE [neovide::channel_utils] neovim_handler ModeChange { mode: Normal, mode_index: 0 }
TRACE [neovide::channel_utils] neovim_handler Flush
TRACE [neovide::bridge::handler] Neovim notification: "redraw"
TRACE [neovide::channel_utils] neovim_handler GridLine { grid: 4, row: 0, column_start: 95, cells: [GridLineCell { text: " ", highlight_id: Some(1426), repeat: None }, GridLineCell { text: " ", highlight_id: Some(0), repeat: Some(0) }] }
TRACE [neovide::channel_utils] neovim_handler Flush
TRACE [neovide::editor] Image flushed
TRACE [neovide::editor] send_batch
TRACE [neovide::editor] Image flushed
TRACE [neovide::editor] send_batch
TRACE [neovide::bridge::handler] Neovim notification: "redraw"
TRACE [neovide::channel_utils] neovim_handler GridLine { grid: 1, row: 59, column_start: 0, cells: [GridLineCell { text: " ", highlight_id: Some(679), repeat: None }, GridLineCell { text: "N", highlight_id: None, repeat: None }, GridLineCell { text: "O", highlight_id: None, repeat: None }, GridLineCell { text: "R", highlight_id: None, repeat: None }, GridLineCell { text: "M", highlight_id: None, repeat: None }, GridLineCell { text: "A", highlight_id: None, repeat: None }, GridLineCell { text: "L", highlight_id: None, repeat: None }, GridLineCell { text: " ", highlight_id: None, repeat: None }, GridLineCell { text: "\u{e0b0}", highlight_id: Some(1454), repeat: None }, GridLineCell { text: " ", highlight_id: Some(695), repeat: None }, GridLineCell { text: "\u{f487}", highlight_id: None, repeat: None }, GridLineCell { text: " ", highlight_id: None, repeat: None }, GridLineCell { text: "3", highlight_id: None, repeat: None }, GridLineCell { text: " ", highlight_id: None, repeat: None }, GridLineCell { text: " ", highlight_id: Some(681), repeat: Some(75) }, GridLineCell { text: "\u{e712}", highlight_id: None, repeat: None }, GridLineCell { text: " ", highlight_id: None, repeat: None }, GridLineCell { text: "\u{e0b2}", highlight_id: Some(1441), repeat: None }, GridLineCell { text: " ", highlight_id: Some(680), repeat: None }, GridLineCell { text: "T", highlight_id: None, repeat: None }, GridLineCell { text: "o", highlight_id: None, repeat: None }, GridLineCell { text: "p", highlight_id: None, repeat: None }, GridLineCell { text: " ", highlight_id: None, repeat: None }, GridLineCell { text: "\u{e0b2}", highlight_id: Some(1442), repeat: None }, GridLineCell { text: " ", highlight_id: Some(679), repeat: Some(3) }, GridLineCell { text: "1", highlight_id: None, repeat: None }, GridLineCell { text: ":", highlight_id: None, repeat: None }, GridLineCell { text: "1", highlight_id: None, repeat: None }, GridLineCell { text: " ", highlight_id: Some(679), repeat: Some(2) }, GridLineCell { text: " ", highlight_id: Some(0), repeat: Some(0) }] }
TRACE [neovide::channel_utils] neovim_handler WindowViewport { grid: 2, top_line: 0.0, bottom_line: 2.0, current_line: 0.0, current_column: 0.0, line_count: Some(1.0), scroll_delta: Some(0.0) }
TRACE [neovide::channel_utils] neovim_handler Flush
TRACE [neovide::editor] Image flushed
TRACE [neovide::editor] send_batch
TRACE [neovide::renderer::rendered_window] Handling Viewport 2
TRACE [neovide::window::keyboard_manager] KeyEvent {
physical_key: Code(
IntlYen,
),
logical_key: Character(
"\",
),
text: None,
location: Standard,
state: Released,
repeat: false,
platform_specific: KeyEventExtra {
text_with_all_modifiers: Some(
"\",
),
key_without_modifiers: Character(
"¥",
),
},
}
TRACE [neovide::window::keyboard_manager] KeyEvent {
physical_key: Code(
AltLeft,
),
logical_key: Named(
Alt,
),
text: None,
location: Left,
state: Released,
repeat: false,
platform_specific: KeyEventExtra {
text_with_all_modifiers: None,
key_without_modifiers: Named(
Alt,
),
},
}
TRACE [neovide::window::keyboard_manager] Modifiers { state: ModifiersState(0x0), pressed_mods: ModifiersKeys(0x0) }
TRACE [neovide::channel_utils] UICommand Parallel(FocusLost)

Additional context
Macbook is a M1 Apple Silicon model. The keyboard layout is JIS (Japanese). The same result happens whether using the built-in keyboard of the Macbook or when using an external Keychron keyboard (Also JIS layout).

@Lokechu Lokechu added the bug Something isn't working label May 8, 2024
@Lokechu
Copy link
Author

Lokechu commented May 10, 2024

While discussing this issue with @fredizzimo in the discord support channel, it was suggested to use the following key remapping:

  vim.keymap.set(
      {'n', 'v', 's', 'x', 'o', 'i', 'l', 't', 'c'},
      '<M-¥>',
      '\\',
      { noremap = true, silent = true }
  )
end

I don't understand the root cause though since the log shows they key event correctly and even the return of:
text_with_all_modifiers: Some( "\", )

However, this workaround does result in the expected behavior and I am satisfied as a result.

@fredizzimo
Copy link
Member

The core issue is that if https://neovide.dev/configuration.html#macos-option-key-is-meta, is set then it will prefer the <M-¥> variation and sent that to Neovim. On keyboards with two alt-keys it can be worked around in Neovim 0.13.0 by specifying that only one of the keys does that. But since your laptop only has one alt key, then a custom mapping has to be used for the keys you want to use as regular characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants