PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Lock the numeric keypad to always and forever use numbers

Open titoBouzout opened this issue 5 years ago • 19 comments

Summary of the new feature/enhancement

The numeric keypad has two states, use like numbers or use like idk navigation and idk what else. I wanna just use the numbers and I want it to never ever again change to anything else than numbers. Is very annoying it keeps changing.

Proposed technical implementation details (optional)

Just lock it in the numeric keypad state and prevent any state switch, forever. Thank you!

titoBouzout avatar Jan 31 '20 19:01 titoBouzout

OMG YES!

crutkas avatar Jan 31 '20 23:01 crutkas

I would like to expand and give some reasons for this:

  1. The very obvious one, most people expect that thing to just enter numbers on the screen, if you press and no number is seen and the cursor moves weird then you are into problems.

  2. The other that isnt that obvious, people that don't speak English does some keyboard gymnastics with ALT+NUMBERS to type some characters that aren't currently on the keyboard. Like ñ @ etc.....

  3. Developers do something similar to the second point, for example Spanish keyboard has the special keys > < to the left of the Z but English keyboards don't have it. So if you use an english keyboard(like most imported[sic] laptops this days) with a Spanish setup you have to resort to stuff like ALT+62 and ALT+60. Dont make me tell you what you have to do to type regular expressions like ^ [] { } etc......

  4. This is a new reason for me, my keyboard just broke, so the 7 key(Numeric keypad one) is not working properly, whenever I hit it, it drives me crazy because I never know if I turned ON Num Lock on or not as the key misbehave! And thats why I entered this issue..... lol

titoBouzout avatar Feb 05 '20 02:02 titoBouzout

It looks like there is no Windows way to lock the num-lock key. We can, however (at least I think this should work):

  • get the current NumLock state and if needed toggle it. There is even MSDN example of exactly this.
  • use keyboard hook to intercept and ignore all NumLock key presses.
  • unfortunately, if PT are not running as admin, we won't be able to intercept NumLock keys in elevated apps. We should probably test the NumLock state from time to time and restore it if it was changed.

This is a great thing for a first-time contribution. A new, separate, small powertoy.

bzoz avatar Feb 06 '20 10:02 bzoz

Well, here is a temporal AHK script courtesy of @boredofnames


#NoEnv
#InstallKeybdHook
SetNumLockState, AlwaysOn

titoBouzout avatar Feb 07 '20 16:02 titoBouzout

unfortunately, if PT are not running as admin, we won't be able to intercept NumLock keys in elevated apps.

If PT utilized the uiAccess="true" attribute in its manifest (and met all of the requirements for that), it would be possible for PT to intercept keystrokes destined for elevated apps when PT itself is not running as admin. The requirements and effects of this attribute are documented under Security Considerations for Assistive Technologies.

Lexikos avatar Jul 04 '20 04:07 Lexikos

If the key remapper supported mapping a key to nothing, this functionality could be built into the existing module. I suppose it matters whether the goal is to make the numpad always output numbers or to stop Num Lock from actuating.

Right now if you attempt to select none, there is a popup stating "Shortcuts must contain an action key". If instead selecting none just intercepted the keypress, I think that'd be a clean solution.

I haven't contributed to open source before, but I've looked at the contributor's guide and I'd be interested in trying to implement that.

jmahlers avatar Aug 28 '20 04:08 jmahlers

Can't you just break the NumLock key out of your keyboard?

Jay-o-Way avatar Sep 05 '20 12:09 Jay-o-Way

Well, here is a temporal AHK script courtesy of @boredofnames


#NoEnv
#InstallKeybdHook
SetNumLockState, AlwaysOn

Did this also prevent Numkock from state change while booting up a VM with Windows 10? Can the user enable NumLock within the VM when the state change is blocked on the host?

htcfreek avatar Sep 10 '20 04:09 htcfreek

Since my suggestion is very similar to this, I'd like to add here that I would very much like if we could do the same thing with caps lock. I'd like to be able to keep it (almost) always off, possibly with Win+CapsLock turning it on until either turned off again or the system idles for a set period of time.

dixonte avatar Sep 12 '21 07:09 dixonte

+1 for what dixonte said, let us permanently enable caps and num lock (and even scroll lock for that matter).

It's such a waste of keys, I don't know a single person that uses them for their intended purpose, either people just never press them, or, like me, they have remapped both keys to other keys as to not waste two keys that are located (especially caps lock) at areas you often use on the keyboard.

holodrum avatar Nov 15 '21 02:11 holodrum

Does it work? Can someone teach me how I always keep the num lock key enabled?

udobehm avatar Jul 07 '22 13:07 udobehm

@udobehm yes it works, download autohotkey https://www.autohotkey.com/ then create a file named "numlock.ahk" with content

#NoEnv
#InstallKeybdHook
SetNumLockState, AlwaysOn

right click the file and choose "compile script", it will create an exe file, that you can run and also add to windows start up

titoBouzout avatar Jul 08 '22 13:07 titoBouzout

Thanks - will try this out

udobehm avatar Jul 09 '22 21:07 udobehm

Does this still need help implementing? I'd like to take this up as it is marked as Good First issue.

vamsivadrevu avatar Apr 18 '23 12:04 vamsivadrevu

@vamsivadrevu what's your idea/solution?

Jay-o-Way avatar Apr 18 '23 12:04 Jay-o-Way

Well, here is a temporal AHK script courtesy of @boredofnames

#NoEnv
#InstallKeybdHook
SetNumLockState, AlwaysOn

this is cool but it will interfere with keyboard lighting, I tried already. It would be nice to have the default set to numbers (indicator light or special lighting scheme shut off) instead of navigation, which is very weird anyway

taiottavios avatar Feb 07 '24 08:02 taiottavios

Hello, im from CZ, we use this weird symbols like čěšáčěšč xDD.
Some websites just interpretes ř as 5, or % to 5 for example (2fa auth). at least for 60% keyboard kayouts.

this is example char map const charToNumberMap = { '0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9', '`': '1', '±': '1', '¡': '1', '²': '2', '³': '3', '£': '4', '$': '5', '%': '5', '¥': '5', '€': '5', '₣': '5', '@': '2', '#': '3', '§': '5', '&': '7', '*': '8', '(': '9', ')': '0', '-': '1', '=': '1', '[': '1', ']': '1', '{': '1', '}': '1', ';': '1', ''': '1', ',': '2', '.': '3', '/': '4', '\': '1', '|': '1', ':': '1', '"': '1', '<': '7', '>': '8', '?': '4', '¡': '1', '¿': '5', '´': '5', '¸': '5', 'ˇ': '5', '˘': '5', '°': '1', '˙': '1', '˛': '5', 'ϴ': '5', 'ρ': '5', 'α': '1', 'β': '2', 'γ': '3', 'δ': '4', 'ε': '5', 'ζ': '6', 'η': '7', 'θ': '8', 'ι': '9', 'κ': '0', 'λ': '1', 'μ': '2', 'ν': '3', 'ξ': '4', 'ο': '5', 'π': '6', 'ρ': '7', 'σ': '8', 'τ': '9', 'υ': '0', 'φ': '1', 'χ': '2', 'ψ': '3', 'ω': '4', 'Ά': '1', 'Έ': '2', 'Ί': '3', 'Ό': '4', 'Ύ': '5', 'Ή': '6', 'Ϊ': '7', 'Ϋ': '8', 'Α': '1', 'Β': '2', 'Γ': '3', 'Δ': '4', 'Ε': '5', 'Ζ': '6', 'Η': '7', 'Θ': '8', 'Ι': '9', 'Κ': '0', 'Λ': '1', 'Μ': '2', 'Ν': '3', 'Ξ': '4', 'Ο': '5', 'Π': '6', 'Ρ': '7', 'Σ': '8', 'Τ': '9', 'Υ': '0', 'Φ': '1', 'Χ': '2', 'Ψ': '3', 'Ω': '4', 'А': '1', 'Б': '2', 'В': '3', 'Г': '4', 'Д': '5', 'Е': '6', 'Ё': '7', 'Ж': '8', 'З': '9', 'И': '0', 'Й': '1', 'К': '2', 'Л': '3', 'М': '4', 'Н': '5', 'О': '6', 'П': '7', 'Р': '8', 'С': '9', 'Т': '0', 'У': '1', 'Ф': '2', 'Х': '3', 'Ц': '4', 'Ч': '5', 'Ш': '6', 'Щ': '7', 'Ь': '8', 'Ы': '9', 'Ъ': '0', 'Э': '1', 'Ю': '2', 'Я': '3', 'А': '1', 'Б': '2', 'В': '3', 'Г': '4', 'Д': '5', 'Е': '6', 'Ё': '7', 'Ж': '8', 'З': '9', 'И': '0', 'Й': '1', 'К': '2', 'Л': '3', 'М': '4', 'Н': '5', 'О': '6', 'П': '7', 'Р': '8', 'С': '9', 'Т': '0', 'У': '1', 'Ф': '2', 'Х': '3', 'Ц': '4', 'Ч': '5', 'Ш': '6', 'Щ': '7', 'Ь': '8', 'Ы': '9', 'Ъ': '0', 'Э': '1', 'Ю': '2', 'Я': '3', // Add more mappings as needed for additional characters and symbols }; (generated, so im not sure it its corect)

wallach-game avatar Sep 09 '24 19:09 wallach-game

Hey. I solved with that way https://www.elevenforum.com/t/how-to-permanently-enable-numlock.23740/

buglocker avatar Feb 10 '25 14:02 buglocker

I think the best of both worlds would be a dropdown(true,false,none) to force a state for the default functions for all the keys that are toggles, even when remapped

gkmzfk6um avatar Mar 07 '25 11:03 gkmzfk6um

Hi, I’d like to work on this feature.

Proposal: Add a small utility (either as a new module or inside Keyboard Manager) that can keep lock keys (NumLock, CapsLock, ScrollLock) always in the user’s chosen state. For example, keep NumLock always on, or CapsLock always off.

High-level design idea:

  • Event-driven approach: Use a low-level keyboard hook to detect changes to lock keys, and immediately restore the configured state.
  • Session / power events: On resume, unlock, or RDP attach/detach, re-assert the desired state, since these changes may not generate key events.
  • Optional fallback: Very low-frequency health check (disabled by default) for rare cases where the state changes without an input event.

Settings:

  • Enable/disable per lock key (NumLock, CapsLock, ScrollLock).
  • Choose target state (On/Off).
  • Optional temporary override shortcut (e.g. Win+NumLock) to let the user change state for a short time.

Permission note: If PowerToys runs as admin, the hook also covers elevated apps; otherwise it only applies within the same integrity level.

From what I can see, there is no active PR or assigned owner for this. Could you please confirm if this direction makes sense and if I can start working on a spec / prototype?

Also, I’m new to contributing to open source projects. I noticed this issue has the good first issue / help wanted labels, so I thought this would be a good opportunity to get involved. Any guidance would be appreciated.

Thanks!

YQ157 avatar Sep 17 '25 06:09 YQ157