<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def transform(self, keys):
 """Apply Spanish layout to the pressed keys"""

        key = keys['regular'][0]
        modifiers = keys['modifiers']

        try:
            if not modifiers:
                if key in self._letters or key in self._digits:
                    res = key
                elif key in self._command_keys:
                    res = '<' + key + '>'
                else:
                    res = self._layout['no_mods'][key]
            elif self._only_shifts(modifiers):
                if key in self._letters:
                    res = key.upper()
                else:
                    res = self._layout['shift'][key]
            elif self._only_right_alt(modifiers):
                res = self._layout['right_alt'][key]
            else:
                res = None
        except KeyError:
            res = None

        return res