Git Product home page Git Product logo

Comments (7)

thomasjo avatar thomasjo commented on August 20, 2024 1

Numpad support is still a thing - I realize I can type numbers with it. The issue is titled "Numeric keypad bindings no longer work" (as I imagine they once did in that tutorial post). I'm not saying I can't type numbers on the keypad. I'm saying I can't bind functions to the num keypad without remapping all numbers on the keyboard (and we all still need to type numbers)

If you use the Keybinding Resolver, while pressing one of the numpad keys, you will see that these keys are being registered as numpad0, numpad1, and so on. Therefore, you should be able to map to these keys specifically.

from atom-keymap.

thomasjo avatar thomasjo commented on August 20, 2024

This is not something new; the issue you're referring to (#42) was closed over 3 years ago when #44 was merged. If you're seeing a recent regression somehow, please let us know and re-open this issue and provide the necessary level of detail needed to reproduce the regression.

Numpad support is still a thing, but only when used as a numeric keypad; we support Num Lock.

Given the reasons this was removed (see original issues), and the fact we do support the numpad when it is actually a numeric keypad, I'm going to close this issue. If someone wants to work on PR for making the proposed opt-in support for "non-numpad numpad", feel free to do so 🙇‍♂️

from atom-keymap.

eric-777 avatar eric-777 commented on August 20, 2024

Whether numlock is on or off, numpad keys return different scan codes and all programming editors I've used before allow them to be mapped uniquely. Even Atom used to do so. I realize #42 is quite old, but I am a new user to Atom and was surprised to find numpad keys un-configurable, especially after reading an internet tutorial on how to configure them in Atom (https://blog.wislon.io/posts/2014/07/14/atom-editor-bind-number-keypad). I was suggesting perhaps the feature be re-introduced in a way that wouldn't trip up anyone who expects numlock to be forever locked in the 'on' position.

Numpad support is still a thing - I realize I can type numbers with it. The issue is titled "Numeric keypad bindings no longer work" (as I imagine they once did in that tutorial post). I'm not saying I can't type numbers on the keypad. I'm saying I can't bind functions to the num keypad without remapping all numbers on the keyboard (and we all still need to type numbers)

from atom-keymap.

eric-777 avatar eric-777 commented on August 20, 2024

I see. This appears to work for 0-9. When numlock is active, the keybinding resolver reports numpad0 through numpad9. With numlock inactive I get up/down/left/right/etc... So with numlock active I can uniquely identify numpad number keys, and with numlock inactive they are ambiguous with up/down/left/right/etc.

That might be workable for me (though not ideal, as I use all other applications with numlock off). However, whether numlock is on or off, the numkeys for slash/star/minus/plus/enter are ambiguous with their non-numpad counterparts according to the keybinding resolver. Also, num-delete is ambiguous with period with numlock on, and ambiguous with delete with numlock off.

I apologize for not being more thorough in my original post. Num-star is the first key I rebind in any editor (to 'undo' - a BRIEF-ism) and this was the source of my numpad issues in Atom. In particular, num-star, num-plus, num-minus, and num-insert are of high importance to me as BRIEF keys.

The tutorial at https://blog.wislon.io/posts/2014/07/14/atom-editor-bind-number-keypad looks like exactly what I'm looking for. I wish this capability were still accessible, but I respect that an editor can't always be everything to every one. I would be a grateful user if it could be replaced somehow.

from atom-keymap.

nathansobo avatar nathansobo commented on August 20, 2024

@eric-777 You can assign a custom keystroke resolver in your Atom init script to customize how Atom maps a given DOM keyboard event to a keystroke string.

There is probably some state in the event you could use to treat the numeric keypad keys specially. Logging the events to the console should give you a quick idea of whether what you're after is possible via DOM APIs.

from atom-keymap.

Ben3eeE avatar Ben3eeE commented on August 20, 2024

You can check the location of the event

To your init scipt:

atom.keymaps.addKeystrokeResolver ({event}) ->
  if event.location is 3
    return add-my-resolver-here

from atom-keymap.

eric-777 avatar eric-777 commented on August 20, 2024

@nathansobo Thankyou!!!!! I followed that link, researched how to add a keystroke resolver to init.coffee, and I have exactly what I'm looking for now. All numpad keys are now uniquely configurable, and behave identically whether numlock is on or off. I didn't realize you could hook the input any lower than the keymap.cson file.

In case anyone else is looking for the same thing, I've added the following to my init.coffee:

atom.keymaps.addKeystrokeResolver ({event}) ->
	if event.type is 'keyup' or event.code[0] isnt 'N'
		return ""
	if event.code is "Numpad0"
		return "num_0"
	if event.code is "Numpad1"
		return "num_1"
	if event.code is "Numpad2"
		return "num_2"
	if event.code is "Numpad3"
		return "num_3"
	if event.code is "Numpad4"
		return "num_4"
	if event.code is "Numpad5"
		return "num_5"
	if event.code is "Numpad6"
		return "num_6"
	if event.code is "Numpad7"
		return "num_7"
	if event.code is "Numpad8"
		return "num_8"
	if event.code is "Numpad9"
		return "num_9"
	if event.code is "NumpadDivide"
		return "num_slash"
	if event.code is "NumpadMultiply"
		return "num_star"
	if event.code is "NumpadSubtract"
		return "num_minus"
	if event.code is "NumpadAdd"
		return "num_plus"
	if event.code is "NumpadEnter"
		return "num_enter"
	if event.code is "NumpadDecimal"
		return "num_delete"

The event.code parameter was sufficient for distinguishing numpad keys from non-numpad keys. If this function returns a non-empty string, that string is preferentially used to index the keymap. I'm sure that's oversimplified, it's just my current understanding.

from atom-keymap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.