if event.type == KEYDOWN:
     if event.key == K_SPACE:
         toggle_pause()
     elif event.key == K_UP:
         increase_speed()
     elif event.key == K_DOWN:
         decrease_speed()
     elif event.key == K_r:
         the_game.reset_grid()
     elif event.key == K_RETURN:
         the_game.random_grid_init()
     elif event.key == K_g:
         mouse_position = pygame.mouse.get_pos()
         if is_on_grid(mouse_position):
             square_location = the_grid.get_square_location(mouse_position)
             the_game.insert_glider(square_location)
     elif event.key == K_p:
         mouse_position = pygame.mouse.get_pos()
         if is_on_grid(mouse_position):
             square_location = the_grid.get_square_location(mouse_position)
             loc = (square_location[0] - 7, square_location[1] - 7)
             the_game.insert_pulsar(loc)
 if event.type == MOUSEBUTTONUP:
     if paused:
         mouse_position = pygame.mouse.get_pos()
         if is_on_grid(mouse_position):
             square_location = the_grid.get_square_location(mouse_position)
             if the_game.grid[square_location[0]][square_location[1]] == GameOfLife.ALIVE:
                 the_game.grid[square_location[0]][square_location[1]] = GameOfLife.DEAD
             else:
                 the_game.grid[square_location[0]][square_location[1]] = GameOfLife.ALIVE