I liked my own idea better [0] - this patch moves the keyboard handling into a shell script as a whole. It probably doesn't apply cleanly right now and I would assist you in updating it. I'm generally in favor atomizing the kinds of functionality involved.
cheers! mar77i [0] https://github.com/mar77i/dwm-patches/tree/master/keys