It's an interesting idea! For the moment, let's assume that you want to map just the 'f' key. The approach that comes to my mind is to map the key to a function that checks if there are any windows open. If there are no windows open, it launches dmenu, pre-populating it with the character you just typed (i.e., the 'f'). If there are other windows open, it does whatever you normally want that key to do.
main = xmonad $ blah blah blah
`additionalKeys`
[
((0, xK_f), multiMapKey f someAction)
-- other mappings
]
multiMapKey :: Char -> X () -> X ()
multiMapKey c someAction =
if ?a window is open?
then launch dmenu with c already entered
else someAction
Notes:
- I don't know how to find out if a window is already open, but I suspect you'll find a function for this in the xmonad or xmonad-contrib package.
- I don't know how to launch dmenu with a character already typed. Maybe there's something in XMonad.Util.Dmenu that will help.
- I think you'll have to have a separate entry in
additionalKeys
for each key you want to map. Maybe just mapping the 26 alphabetic keys will be sufficient.
For learning more about the Xmonad innards, I recommend jekor's videos: part 1 part 2