I was going to write this in a comment, but it became too long. It might not be the answer you're looking for...
If you think of the logic in your code, it seems what will happen when you press a key that is not enter is that the handleEvent will run and the velocity will be adjusted, and when you finally press enter the move loop takes over and starts moving the sprite, but... if you pressed up once and down once, the velocity will be unchanged as the moves counteract each other, and the move will be two times nothing.
What you need to do is to defer the handling of events until you press return altogether, so that you start processing the events only after you hit enter.
If you add the events to a std::queue<SDL_Event>
(using queue.push_back(e)
) you can retrieve them in a loop after you hit enter and for each event call the handleEvent and move functions, possibly with a small delay if you actually want to see the moves performed stepwise.
it could look something like this:
while (!queue.empty())
{
SDL_Event e = queue.front();
sprite1.handleEvent(e);
SDL_RenderClear(renderer);
drawTiles(xTiles, yTiles, background, renderer);
sprite1.move();
drawImages(image, image2, image3, sprite1, renderer);
SDL_Delay(200); // possible delay.
SDL_RenderPresent(renderer);
queue.pop();
}