1SDL_keysym(3)                  SDL API Reference                 SDL_keysym(3)
2
3
4

NAME

6       SDL_keysym - Keysym structure
7

STRUCTURE DEFINITION

9       typedef struct{
10         Uint8 scancode;
11         SDLKey sym;
12         SDLMod mod;
13         Uint16 unicode;
14       } SDL_keysym;
15

STRUCTURE DATA

17       scancode            Hardware specific scancode
18
19       sym                 SDL virtual keysym
20
21       mod                 Current key modifiers
22
23       unicode             Translated character
24

DESCRIPTION

26       The  SDL_keysym structure is used by reporting key presses and releases
27       since it is a part of the SDL_KeyboardEvent.
28
29       The scancode field should generally be left alone, it is  the  hardware
30       dependent scancode returned by the keyboard. The sym field is extremely
31       useful. It is the SDL-defined value of the key (see SDL Key Syms.  This
32       field  is  very  useful  when you are checking for certain key presses,
33       like so:
34
35       .
36       .
37       while(SDL_PollEvent(&event)){
38         switch(event.type){
39           case SDL_KEYDOWN:
40             if(event.key.keysym.sym==SDLK_LEFT)
41               move_left();
42             break;
43           .
44           .
45           .
46         }
47       }
48       .
49       .
50
51        mod stores the current state of the keyboard modifiers as explained in
52       SDL_GetModState.  The  unicode is only used when UNICODE translation is
53       enabled with SDL_EnableUNICODE. If unicode is non-zero then this a  the
54       UNICODE  character corresponding to the keypress. If the high 9 bits of
55       the character are 0, then this maps to the equivalent ASCII character:
56
57       char ch;
58       if ( (keysym.unicode & 0xFF80) == 0 ) {
59         ch = keysym.unicode & 0x7F;
60       }
61       else {
62         printf("An International Character.
63       ");
64       }
65
66        UNICODE translation does have a slight overhead  so  don't  enable  it
67       unless its needed.
68

SEE ALSO

70       SDLKey
71
72
73
74SDL                         Tue 11 Sep 2001, 23:00               SDL_keysym(3)
Impressum