This version is old school.
Please find jQuery plugins on npm.
jQuery Caps Lock State
by Jason Ellison
jQuery plugin for monitoring and reporting the state of the Caps Lock key. Tracks at the document level instead of individual fields, and works with all keyboard layouts.