keyboard - "Listening" for media key press events -
i'm writing application in c++ needs able listen key presses occur in linux, namely media next, media previous, , media play/pause.
what apis exist enable me listen keypresses? assume enduser running x, if they're not, there "guaranteed™" way catch media key presses no matter what?
i'm bit new writing c++ , relates linux, i'm in no way new linux (just getting used living on bare metal).
i not sure extent globally under x using xlib event handlers. sans x, believe require kernelspace component, if really wanted this, might best bet.
however, it's not idea. did not trying do, think falls 1 of 2 categories: either want use keys operate app (case a) or want app monitor use of application uses keys (case b).
in case a, it's not idea because associating global keystrokes actions domain of window managers/desktop environments (the associations should dynamic, not hard-coded), , when decide make own rules ignoring fact, users , other developers unlikely appreciate it. if want app respond global key presses, create client , server parts such client can bound keypress window manager (as configured user), , pass messages on daemon server. not try , short-circuit or by-pass these existing conventions no reason (e.g., because ostensibly makes task easier or because want hardcode particular keys). create app can bound whatever keys user via window manager.
in case b, less friendly territory, because trying create keylogger. , again, if really determined might want around keylogging kernel module (pretty sure that's takes) adapt, keeping in mind few people going want use software has resort such (if you, doesn't matter, still poor lesson in design). finally, if doing because trying introduce external functionality use of you associate use of various media keys, don't, because whatever is, isn't hardcoded keys anyway: it's default of window manager.
Comments
Post a Comment