<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def button_pressed(self, key_code, prefix=None):
 """ Called from the controller classes to update the state of this button manager when a button is pressed. :internal: :param key_code: The code specified when populating Button instances :param prefix: Applied to key code if present """

        if prefix is not None:
            state = self.buttons_by_code.get(prefix + str(key_code))
        else:
            state = self.buttons_by_code.get(key_code)
        if state is not None:
            for handler in state.button_handlers:
                handler(state.button)
            state.is_pressed = True
            state.last_pressed = time()
            state.was_pressed_since_last_check = True
        else:
            logger.debug('Unknown button code {} ({})'.format(key_code, prefix))