How to Set Num Lock on permanently

When I use my Windows laptop, I’m always accidentally brushing against the Num Lock key. I suppose it’s because the keys are so flat; I never have this problem on a desktop.

I thought there must be some way to set it so that it’s always on, so I searched for it. First I found articles on how to turn Num Lock on at startup, but that’s not my problem. The key already is on when I start up, but it doesn’t stay on when I brush against it.

Next I found articles say to set a certain registry key. That didn’t work for me, and apparently a lot of other people have the same experience.

Some articles say to edit your BIOS. My understanding is that you can edit the BIOS to permanently disable the key, but I wanted to permanently enable the key.

Here’s what did work: give AutoHotKey the command

    SetNumLockState, AlwaysOn

I haven’t used AutoHotKey before. I’ve heard good things it, but it seems like it can be quite a deep rabbit hole. I intend to look into it a little, but for now I just want my Num Lock to stay on.

After you install AutoHotKey and run it, you get its help browser, not the app per se, and it’s not immediately obvious how to run the code above. You need to save the line of code to a file whose name ends in .ahk, such as numlock.ahk. If you double-click on that file, it will run the AutoHotKey script. To make it run automatically when your computer starts up, put the script in your Startup folder. This is probably

    C:\Users\...\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

You can bring up the Startup folder by typing Windows key + R, then shell:startup.

Related post: Remapping the Caps Lock key

7 thoughts on “How to Set Num Lock on permanently

  1. SteveBrooklineMA

    I had a similar impression of AutoHotKey. Very powerful, flexible, and well-designed by a programmer who takes pride in doing it right. And the vast majority of people who use it probably just need something very simple, like having a single button pushed repeatedly in a video game.

    I’m grateful for the program though. In the past I’ve downloaded programs hoping they would do what I need, but ended up disappointed and frustrated. With AutoHotKey I’m confident it can do it, if I can figure out how.

  2. John,
    Thanks for this. It works and works well!
    Thank you for making my day better!!!
    William

  3. Obviously AHK will work, but for whoever play online games, beware, simply having AHK installed on your computer will trigger EasyAntiCheat or any other similar anticheat and get you banned.

    Do not run AHK if you play online, even if it’s idle or running a script for something totally unrelated.

  4. I always did it in registry base by modifying the value of InitialKeyboardIndicators and setting it to “2”. This doesn’t seem to work anymore (at least on my laptop, maybe it’s valable for desktops) but it still has to be possible via registry. No need for 3rd party apps.

  5. Thank you very much.

    I have been looking for some way to do exactly this for years. I tried all the other hacks and don’t trust random freeware apps that tout a solution, as most of them are keyloggers working for criminals.

    I hope this is the end of being ambushed by a silent and unintended switch to the non-numeric mode of my numeric key pad, just when I start keying in numbers by muscle memory but instead get garbage, which has been quite irksome.

  6. No, not reliable… In some circumstances the lock on the NumLock state it circumvented and then you stuck with the off state. We’ve to add a loop and check periodically the Numlock state and re-establish it. It’s a shame for Microsoft not to give an user or admin the ability to configurate that annoyance, which existed since the AT-PC era…

  7. Okay, didn’t wanted to, but in the end I was annoyed enought to have a look into the manual of AutoHotKey…

    The following script tales the current NumLock state and lock it down.
    1) The script takes the current NumLock state and locks it.
    2) If the state is changed by a program, the script restores it on using the Numpad-Keys 0 – 9 and decimal point.
    3) LeftAlt – Win – NumLock toggles the state
    4) Win – NumLock print the current state on screen
    5) any other combination of NumLock is ignored.
    6) How to change the boot state of NumLock with the Registry, please look below in the heather.

    Hope, the script helps.

    —————————————————————————
    ;Glue NumLock
    ;Ver. 1
    ;Autor: ToraxMalu
    ;© 2022-04-25
    ;
    ;Unwanted Change of NumLock-State by User or Software.
    ;The Script takes the initial NumLock state and lock it down.
    ;If NumLock state changed by program or user, the script restores
    ;the fixed state on hitting Numpad 0 – 9 or Decimal-Dot-Key.
    ;
    ;Left-Alt-Win-NumLock: State-change
    ;Win-NumLock: Display State
    ;
    ;To command Windows a initial state after boot,
    ;set in Bios NumLock to “On” or
    ;modify Registry Key HKEY_USERS\.DEFAULT\Control Panel\Keyboard, value InitialKeyboardIndicators
    ;Microsoft modified the behaviour. Depending on System, the default values are 0 or 2147483648.
    ;Add a value of 2.

    ;Initial-commands by AutoHotkey
    #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
    #Warn ; Enable warnings to assist with detecting common errors.
    SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

    ;Take current NumLock-State as initial falue and lock it down.
    CurrentState := GetKeyState(“NumLock”,”T”)
    If (CurrentState = 1)
    TargetState := “On”
    else
    TargetState := “Off”

    PermaState := TargetState

    ;HotKey-Definitions

    ;Play Error-Sound on NumLock
    *NumLock::
    SoundPlay *16
    return

    ;State enquery on Win-NumLock
    #NumLock::
    MsgBox, NumLock-Current permanent setting for NumLock: %PermaState%`nChange with LeftAlt-Win-NumLock
    return

    ;Change permanent state on LeftAlt-Win-NumLock
    <!#NumLock::
    CurrentState := GetKeyState("NumLock","T")
    If (CurrentState = 0)
    TargetState := "On"
    else
    TargetState := "Off"

    PermaState := TargetState
    SetNumLockState, %PermaState%
    SoundPlay *64
    return

    ;Defines for "On"
    #If PermaState = "On"
    NumpadIns::
    +NumpadIns::
    SetStateOn("Numpad0")
    return

    NumpadEnd::
    +NumpadEnd::
    SetStateOn("Numpad1")
    return

    NumpadDown::
    +NumpadDown::
    SetStateOn("Numpad2")
    return

    NumpadPgDn::
    +NumpadPgDn::
    SetStateOn("Numpad3")
    return

    NumpadLeft::
    +NumpadLeft::
    SetStateOn("Numpad4")
    return

    NumpadClear::
    +NumpadClear::
    SetStateOn("Numpad5")
    return

    NumpadRight::
    +NumpadRight::
    SetStateOn("Numpad6")
    return

    NumpadHome::
    +NumpadHome::
    SetStateOn("Numpad7")
    return

    NumpadUp::
    +NumpadUp::
    SetStateOn("Numpad8")
    return

    NumpadPgUp::
    +NumpadPgUp::
    SetStateOn("Numpad9")
    return

    NumpadDel::
    +NumpadDel::
    SetStateOn("NumpadDot")
    return

    SetStateOn(KeyName)
    {
    SendInput {%KeyName%}
    SetNumLockState, On
    }

    ;Defines for Off
    #If PermaState = "Off"
    Numpad0::
    +Numpad0::
    SetStateOff("NumpadIns")
    return

    Numpad1::
    +Numpad1::
    SetStateOff("NumpadEnd")
    return

    Numpad2::
    +Numpad2::
    SetStateOff("NumpadDown")
    return

    Numpad3::
    +Numpad3::
    SetStateOff("NumpadPgDn")
    return

    Numpad4::
    +Numpad4::
    SetStateOff("NumpadLeft")
    return

    Numpad5::
    +Numpad5::
    SetStateOff("NumpadClear")
    return

    Numpad6::
    +Numpad6::
    SetStateOff("NumpadRight")
    return

    Numpad7::
    +Numpad7::
    SetStateOff("NumpadHome")
    return

    Numpad8::
    +Numpad8::
    SetStateOff("NumpadUp")
    return

    Numpad9::
    +Numpad9::
    SetStateOff("NumpadPgUp")
    return

    NumpadDot::
    +NumpadDot::
    SetStateOff("NumpadDel")
    return

    SetStateOff(KeyName)
    {
    SendInput {%KeyName%}
    SetNumLockState, Off
    }

Leave a Reply

Your email address will not be published.