You're basically answering your own question during your question, but for the sake of having an answer, I'll try to answer it to the best of my abilities.
There are different ways, something can become unresponsive.
Lets assume you are using Windows, though the process is not that different for other operating systems.
When you interact with a program, you do so by clicking or typing while the program has focus.
Clicking or Typing goes via the mouse or keyboard to the motherboard. The operating system will query what is being typed and how the mouse is being moved. It interprets the signals and interacts with the programs accordingly.
Keyboard shortcuts will be sent to the active application unless a hotkey is being pressed that has a global status. In that case the operating system will perform a different action.
The operating system will also make the program amongst other programs function without any interaction. For example, when you copy a file from location 1 to location 2, if you don't type anything or not move the mouse, the file copy operation will still continue.
Modern Operating Systems have a feature called Multi Tasking which basically means that it cycles through all programs very fast giving each program time to perform a cycle in its programming. By doing so, it will appear that all programs run at the same time fluently. In this cycle, the Operating System itself will also be given CPU time.
When a program performs lots of calculations, the CPU is being utilized more. The more a CPU is being utilized, the less power is available for the rest of the system, including cycling through all other programs. When the CPU reaches 100% utilization, the computer will become very slow as it is waiting for CPU time to process all the activities by all open programs. The Operating System normally prevents the computer from freezing if this happens, but it is possible the computer can freeze in these occasions.
When a program is being created, it is possible a bug exists which causes the program to crash or become unresponsive when a series of tasks is performed.
There are different levels of unresponsiveness when talking about program bugs. It is possible the program stalls its execution waiting for a certain button to be pressed, but that button appeared outside of the screen. The program works normally, it just does not accept user input and as such appears to be stalled while technically it isn't.
It is possible the program is performing a memory operation but the memory operation refers to a different segment of memory, which again refers to a different segment of memory and along the way ends up refering to the first segment of memory. As a result, a never-ending loop is formed. The program thinks its performing a simple action and expects a result within a few nanoseconds but causes a buffer underrun or overflow. Windows 7 and higher has several protections and will give a critical error: "The program stopped responding and has crashed. Send error report". In earlier versions of windows, depending on how severe the memory loop was, it could result in a Blue Screen of Death.
The Operating System itself is in essense also a program, and has the same problems. It is possible a bug in programming can cause the entire Operating System to become unresponsive.
Lastly, part of the Operating System are programs used to communicate with hardware. These are called drivers. Just like normal programs, a driver can also crash and become unresponsive, although chances for this to happen are less likely to occur. It is possible that the keyboard driver crashes and causes the keyboard to stop responding, while the mouse still works.
The Operating System usually detects driver issues and attempts to restart the driver. Depending on how well the driver was programmed determines how much the user finds hinder of the crash. Sometimes it may cause a flicker of the display and nothing more, sometimes a popup is shown indicating that the driver was crashed and restarted.
Plug and Play drivers usually are stable and don't crash. Custom drivers for specific hardware may crash more easily because the chances are higher some bugs have not been found yet.
With the above explained, its time to answer the question.
As indicated, a crash can happen for different reasons and with different severity. If the CapsLock key will trigger the LED light requires two things. It requires the driver to be functioning, and it requires the Operating System to give time to process the programming cycle of the driver (the multitasking part I mentioned earlier)
If both are true, pressing the Capslock key will do the following:
The key is being pressed on the keyboard and its signal is sent to the motherboard. The Operating System's driver explains to the Operating System what happens and the driver sends a message back to the keyboard that the LED state should change to its new state. The Operating System will use this information to type text in caps. Some programs however turn the LED key off by sending a second capslock signal to the driver. Depending on the keyboard, the CapsLock light may never turn on if this is the case.
If the driver does not get its cycle directly after pressing the caps lock, the LED will not change. But it is possible that the system is very slow for some reason, and the cycle is delayed. In that case it can happen that pressing the capslock or numlock will not immediately change the LED's state, but after a second or two.
Lastly, it is possible, that for some reason on the Operating System Level, it waits cycling through the drivers programming cycle because it waits for something. If this is the case, it is possible the mouse can still be moved, yet the everything else appears to be frozen.
Given that the pc is going to be in serious trouble if normal keyboard LED functions are not working after 5 seconds of time has passed, it can be safely assumed that the system has crashed severely and cannot be recovered.
There are two other keys, namely Scroll Lock and Numlock. From these three keys, Numlock is the only key that other programs likely won't abuse due to the nature of what the key does. It is more reliable to use numlock to test if the system is responsive or not than the capslock or scroll lock because some programs tend to use these keys to trigger a different function, and as such they often make the LED status to off which makes it less reliable to test with Capslock or scroll lock, and more reliable to test with the numlock.