def _key_press(event, params):
 if (event.key == 'left'):
  params['pause'] = True
  params['frame'] = max((params['frame'] - 1), 0)
 elif (event.key == 'right'):
  params['pause'] = True
  params['frame'] = min((params['frame'] + 1), (len(params['frames']) - 1))

def _key_press ( event , params ) : if ( event . key == 'left' ) : params [ 'pause' ] = True params [ 'frame' ] = max ( ( params [ 'frame' ] - 1 ) , 0 ) elif ( event . key == 'right' ) : params [ 'pause' ] = True params [ 'frame' ] = min ( ( params [ 'frame' ] + 1 ) , ( len ( params [ 'frames' ] ) - 1 ) )
function for handling key presses for the animation .