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

Number Pad navigation doesn't move the cursor #5491

Closed
MM4096 opened this issue Jan 23, 2025 · 9 comments
Closed

Number Pad navigation doesn't move the cursor #5491

MM4096 opened this issue Jan 23, 2025 · 9 comments

Comments

@MM4096
Copy link

MM4096 commented Jan 23, 2025

On any input widget (Input, MaskedInput, TextArea), the buttons on a number pad (such as Home, End, Left, Right, Up, Down) don't move the cursor to the start and end of the line respectively.

Steps to reproduce:

  • Use a keyboard with a dedicated number pad containing navigation buttons
  • Create an application containing a single input
  • Input some random data
  • Try to navigate with the number pad

Through my testing, I can confirm that Number Lock was not enabled, and that the buttons work in other applications; only Textual applications don't seem to respond to these controls.

If it matters, my laptop model is Asus Vivobook 15 (15.6"), and I'm using the built-in number pad.

Copy link

We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@TomJGooding
Copy link
Contributor

TomJGooding commented Jan 23, 2025

Just to double-check, do these keys normally work in your terminal, for example cursoring within a command?

Could you try running textual keys and see what is reported when pressing the numpad navigation keys?

@MM4096
Copy link
Author

MM4096 commented Jan 23, 2025

  1. Yes, I can use the keys to navigate in the terminal
  2. Here's a list of the keys:
Physical Key Result of textual keys
Home kp_home
End kp_end
Page Up kp_page_up
Page Down kp_page_down
Arrow Key Up kp_up
Arrow Key Down kp_down
Arrow Key Left kp_left
Arrow Key Right kp_right
Delete kp_delete
Enter kp_enter
Insert kp_insert

For all the keys, the result seems to have kp_ appended to the key's non-numpad name, except for the number keys.

@TomJGooding
Copy link
Contributor

Thanks for the detailed report, it makes sense now why I couldn't replicate this issue after trying it on my only laptop that has a numpad running Windows!

I assume your terminal is kitty or another terminal that supports the kitty keyboard protocol? It looks like these "functional keys" for numpad navigation might need special handling...

@TomJGooding
Copy link
Contributor

I managed to dig out an old keyboard with a numpad and reproduce this with alacritty (which uses the kitty protocol).

What do you think @willmcgugan? Is there any benefit of distinguishing these keypad keys, or should Textual instead simply map them to the normal keys?

@willmcgugan
Copy link
Collaborator

My git feeling is that is should map them to normal keys, unless there is an argument to the contrary!

I have dug out a keyboard with a numpad. I'll make those changes.

@willmcgugan
Copy link
Collaborator

I didn't get these kp_ prefixes on iTerm. However I do get them on Alacritty. How delightfully fun terminals are!

Going with dropping the prefix for now.

@willmcgugan
Copy link
Collaborator

So some terminals distinguish between these keys. Some do not. I'm not even sure which is correct. I would be surprised by any app that treat them differently.

Fix is in main now.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants