Howto handle modified keys

Daniel Stone daniel at fooishbar.org
Fri Oct 20 04:39:29 PDT 2006


On Fri, Oct 20, 2006 at 11:01:23AM +0200, Philip Pflästerer wrote:
> is there an easy posibility to react on combinations of keyboard-events 
> like ALT+F or something like that? I have implemented an event handler, 
> which reacts on the KeyPress event. When I press the 'ALT'-key, the 
> event handler recognizes it correctly as keycode '64'. When I press the 
> 'f'-key, the event handler recognizes ist correctly as keycode '41'. But 
> when I press 'f' in combination with 'ALT' theres no difference, it 
> first recognizes 'ALT' and than 'f' (depending on chronological order). 
> So how can I handle modified keys?

Look in the state field of the key event, there's Mod[1..4]Mask
available.  I think Alt is generally Mod4.  So a key press of f with
Mod4Mask in state, means Alt-F.

Cheers,
Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg/attachments/20061020/3e6d68ad/attachment.pgp>


More information about the xorg mailing list