Jump to content

Is the Num, caps, and scroll lock controlled by the OS or the hardware?

432

Is the Num, caps, and scroll lock controlled by the OS or the hardware?

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, wat3rmelon_man2 said:

OS.

So the lock keys are soft?

Link to comment
Share on other sites

Link to post
Share on other sites

11 minutes ago, wat3rmelon_man2 said:

OS.

Pretty sure it's hardware. Those keys register in bios, long before the os loads. 

Link to comment
Share on other sites

Link to post
Share on other sites

They are hardware, but there are some keyboards where you can rebind them, at least scroll lock, I have on my Ducky keyboard. Haven't tried caps lock and my keyboard doesn't have mum lock.

“Remember to look up at the stars and not down at your feet. Try to make sense of what you see and wonder about what makes the universe exist. Be curious. And however difficult life may seem, there is always something you can do and succeed at. 
It matters that you don't just give up.”

-Stephen Hawking

Link to comment
Share on other sites

Link to post
Share on other sites

16 minutes ago, Blue4130 said:

Pretty sure it's hardware. Those keys register in bios, long before the os loads. 

It's both/neither actually. The keyboard sends a signal that equates to a keycode. The "OS" maps that to some functionality. Here, "OS" doesn't necessarily mean a full blown operating system like Windows. The BIOS acts as Windows would in this situation, mapping the keycode to some functionality.

 

In other words, the keyboard controls what is sent, but there has to be something on the other end that interprets it and does something with that.

CPU: AMD Ryzen 9 5900X · Cooler: Artic Liquid Freezer II 280 · Motherboard: MSI MEG X570 Unify · RAM: G.skill Ripjaws V 2x16GB 3600MHz CL16 (2Rx8) · Graphics Card: ASUS GeForce RTX 3060 Ti TUF Gaming · Boot Drive: 500GB WD Black SN750 M.2 NVMe SSD · Game Drive: 2TB Crucial MX500 SATA SSD · PSU: Corsair White RM850x 850W 80+ Gold · Case: Corsair 4000D Airflow · Monitor: MSI Optix MAG342CQR 34” UWQHD 3440x1440 144Hz · Keyboard: Corsair K100 RGB Optical-Mechanical Gaming Keyboard (OPX Switch) · Mouse: Corsair Ironclaw RGB Wireless Gaming Mouse

Link to comment
Share on other sites

Link to post
Share on other sites

I think it can vary by the keyboard. I had two wireless number pads once, on one the numlock key was a 'live' key that I was able to rebind using autohotkey, but on the other the numlock key was a 'hardware' key that just shifted the function of the other keys on the number pad (ie, it was not picked up as a keypress by the OS and able to be rebound by autohotkey)   

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Chris Pratt said:

It's both/neither actually. The keyboard sends a signal that equates to a keycode. The "OS" maps that to some functionality. Here, "OS" doesn't necessarily mean a full blown operating system like Windows. The BIOS acts as Windows would in this situation, mapping the keycode to some functionality.

So it's "hard" in BIOS, but "soft" when the OS loads?

Link to comment
Share on other sites

Link to post
Share on other sites

If USB keyboards follow the same idea as PS/2 keyboards, it's software based.

This video:

(at 27:29 he brings up Shift/Caps Lock/etc., but you do need some of the context of the rest of the video)

And its USB counterpart:

Spoiler

 

Might be interesting to you.

 

I will now explain a bit how the PS/2 protocol works, but this applies to USB too; except it's just a lot more difficult in USB.

Simply put, your keyboard sends 'scan codes'  to your PC. Basically a bit of data to tell you what key you pressed. Some scancodes have 'longer' scancodes though.

Things like all the alpha-numeric keys have their own scancodes, but also all the modifiers, such as shift, caps, etc.

 

Your keyboard doesn't track whether your numlock is pressed or not.

You just press caps lock, your computer remembers this and now when you press a letter key on your number pad, your computer figures out "oh right, you pressed capslock back then, so you want a capital of whatever letter you just pressed".

Or if you hold shift and press a number? The computer and its associated keyboard config will decide the special character (which can depend on the keyboard language setting in your OS).

 

TL;DR: in software, it remember the toggle keys, or sees you pressed a modifier + letter/number and decides what the output is.

 

EDIT: a simple way to prove it's the OS that remembers the state of a toggle key, is by pressing CAPS lock (or any other toggle key), unplugging it and plugging it back in.

You'll notice the CAPS lock toggle is still set to on. Keyboards use momentary switches (not toggle switches) and don't have battery backups to be able to remember the toggle was set to on. The software (whether that be your OS, BIOS, etc.) remembers the toggles and decides what to do with the incoming scan codes, based on if the toggle is on/off.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, 432 said:

So it's "hard" in BIOS, but "soft" when the OS loads?

No. The distinction between hard and soft doesn't make sense even. It's up to the keyboard to decide what is sent. However, that's just signal. The software side decides what to do with it. It can't work with anything the keyboard doesn't send, so if the keyboard handles NumLock for example entirely itself, literally sending different signals, the software side only knows what it gets, not whether NumLock is activated or not. However the sheer fact that the keyboard sends a particular signal means nothing. The software side can choose to ignore it, do the "normal" thing, or do something entirely different.

 

There's no functional difference here between BIOS and OS other than that both are distinct pieces of software that can choose to do whatever they want with a particular keyboard signal, i.e. one is not ruled by the other.

 

To answer you original question more directly:

 

2 hours ago, 432 said:

Is the Num, caps, and scroll lock controlled by the OS or the hardware?

The keyboard would need to send a signal that those are activated. It doesn't necessarily have to. For example, instead of indicating that the user typed the "A" key and caps lock is activated, the keyboard could just send the keycode for capital "A". The software interpreting the signal, then, only knows what the keyboard sent, not what the user did.

 

Conversely, if the keyboard does indicate that caps lock is on, for example, the receiving software could choose to ignore this info entirely, and still print lowercase. Or, it could do something totally random like open a particular app.

 

Long and short, it's the hardware and software working together that gives a particular result. There is no black and white "it's all hardware" or "it's all software".

CPU: AMD Ryzen 9 5900X · Cooler: Artic Liquid Freezer II 280 · Motherboard: MSI MEG X570 Unify · RAM: G.skill Ripjaws V 2x16GB 3600MHz CL16 (2Rx8) · Graphics Card: ASUS GeForce RTX 3060 Ti TUF Gaming · Boot Drive: 500GB WD Black SN750 M.2 NVMe SSD · Game Drive: 2TB Crucial MX500 SATA SSD · PSU: Corsair White RM850x 850W 80+ Gold · Case: Corsair 4000D Airflow · Monitor: MSI Optix MAG342CQR 34” UWQHD 3440x1440 144Hz · Keyboard: Corsair K100 RGB Optical-Mechanical Gaming Keyboard (OPX Switch) · Mouse: Corsair Ironclaw RGB Wireless Gaming Mouse

Link to comment
Share on other sites

Link to post
Share on other sites

It's all controlled by software, even down to the LEDs on the keyboard. All the keyboard does is send a keycode that tells the computer to toggle caps/num/scroll lock.

Quote me to see my reply!

SPECS:

CPU: Ryzen 7 3700X Motherboard: MSI B450-A Pro Max RAM: 32GB I forget GPU: MSI Vega 56 Storage: 256GB NVMe boot, 512GB Samsung 850 Pro, 1TB WD Blue SSD, 1TB WD Blue HDD PSU: Inwin P85 850w Case: Fractal Design Define C Cooling: Stock for CPU, be quiet! case fans, Morpheus Vega w/ be quiet! Pure Wings 2 for GPU Monitor: 3x Thinkvision P24Q on a Steelcase Eyesite triple monitor stand Mouse: Logitech MX Master 3 Keyboard: Focus FK-9000 (heavily modded) Mousepad: Aliexpress cat special Headphones:  Sennheiser HD598SE and Sony Linkbuds

 

🏳️‍🌈

Link to comment
Share on other sites

Link to post
Share on other sites

As others have said here,  the keyboard sends a signal to the OS. To see this in action, run it in a VM (Virtual machine)

I can have numlock on my host (the physical machine in front of me) then jump inside my virtual machine and num lock is off, since the virtual machine never recieved me pressing num lock.

 

From what I recall, when you press "a" on your keyboard, the keyboard sends a signal for the letter a being pressed. Even if caps lock is turned on, it still sends just that an a has been pressed. My experiance in vm's seems to confirm this, and jumping through vnc, teamviewer, remote tool of the day.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×