Thanks for the help! After some more searching and taking a look at the showkey sources, I was able to recreate most of the functionality of showkey in Perl (at least enough to capture numlock presses). I've posted an example program
here in case anyone else is interested.