I think my patch is better. There is no special case for 0 mask and state and when we match for Ctrl and Shift it works only when they both are pressed. With your patch it will work for Ctrl only or for Shift only.
Maybe it can be adopted for dwm so we would be able to remove this CLEANMASK macro.
diff -r e64c97268f1a st.c --- a/st.c Thu Jun 09 18:25:56 2011 +0200 +++ b/st.c Mon Aug 01 14:31:32 2011 +0300 @@ -1833,8 +1833,9 @@ char* kmap(KeySym k, unsigned int state) { int i; + for(i = 0; i < LEN(key); i++) - if(key[i].k == k && (key[i].mask == 0 || key[i].mask & state)) + if(key[i].k == k && (state & key[i].mask) == key[i].mask) return (char*)key[i].s; return NULL; }