There is no current standard for key events and there doesn't appear to be an event property indicating the state of the caps lock key, though it might be provided in future.
The only reasonably reliable way to test for caps lock seems to be to see if the key code is a capital letter and the shift key is not pressed, e.g.
function capsLockOn(e) {
var code = e.keyCode || w.which;
if (code >64 && code < 97 && !e.shiftKey) {
return true;
}
return false;
}
On some keyboards, the caps lock only affects keys a to z so you can't reliably test others. Pressing the caps lock key doesn't initiate a key event and would not work reliably anyway since the caps lock might be on before there's a chance to initiate an event.
Or if brevity is your thing:
function capsLockOn(e) {
var code = e.keyCode || w.which;
return code > 64 && code < 97 && !e.shiftKey || void 0;
}