[SOLVED]SDL2 keyboard problem lazarus / 62-General ---------------------------------------------------------------------- mrguzgog · 2016-08-15 07:45 I have this little function to check if a key is pressed using SDL: Code: [Select]    function keyPressed(key: longint): boolean;     begin         while SDL_PollEvent(sdlEvent) = 1 do         begin             if sdlEvent^.type_= SDL_KEYDOWN then             begin                 if sdlEvent^.key.keysym.sym = key then exit(true);              end;         end;         exit(false);     end; If I call it using: Code: [Select]if keyPressed(SDLK_Escape) = true then... it works fine, but if I call with... Code: [Select]if keyPressed(SDLK_UP) = true then... it doesn't work. As it compiles properly, SDLK_UP must be defined (somewhere!), maybe I have the wrong type but longint looks to be right. Can someone tell me what I'm doing wrong please? ---------------------------------------------------------------------- mrguzgog · 2016-08-20 15:02 Oops, forgot to mark this as solved, I re-wrote the keyboard routine as follows and it works fine: Code: [Select]    procedure updateKeys();     var     keyPressed: longint;     begin         while SDL_PollEvent(sdlEvent) = 1 do         begin             if sdlEvent^.type_= SDL_KEYDOWN then             begin                 keyPressed := sdlEvent^.key.keysym.sym;                                 case keyPressed of                     SDLK_ESCAPE: ...                     SDLK_UP: ...                 end;                             end;         end;     end;