Ah... the NumLock stuff is a bit of a red herring. Apparently (according to HelpPC), the keyboard gives an alternate set of scan codes for some keys when NumLock is turned on. For example, for the Del key:
[table]
[tr][td][/td][td]Normal[/td][td]NumLock On[/td][/tr]
[tr][td]Make:[/td][td]E0 53[/td][td]E0 2A E0 53[/td][/tr]
[tr][td]Break:[/td][td]E0 D3[/td][td]E0 D3 E0 AA[/td][/tr]
[/table]
Your state diagram explains what I coded better than my words did, but you'll only see the E0 2A codes when NumLock is physically turned on. This NumLock behaviour is independent of turning arrow keys into numbers when NumLock is turned on; you have to do that in software.
I've just put some debugging code into my keyboard driver, and I can confirm that the scan codes for certain keys (e.g. the small cursor keys) change depending on whether the Num Lock LED is on. For example, the left arrow key: (results from an *actual* AT keyboard
)
[table]
[tr][td][/td][td]Normal[/td][td]NumLock On[/td][/tr]
[tr][td]Make:[/td][td]E0 4B[/td][td]E0 2A E0 2B[/td][/tr]
[tr][td]Break:[/td][td]E0 CB[/td][td]E0 CB E0 AA[/td][/tr]
[/table]
I also checked the behaviour of Del and it conforms to what HelpPC says (the table at the top of my post).
I'd like to emphasise that this behaviour isn't related to arrows turning to numbers when NumLock is on: note that the codes emitted don't refer to numbers. You have to keep track of the NumLock state the same way as for Caps Lock and do the translations yourself.