Trouble aliasing a function from Yanfly Keyboard Config

I'm trying to alias a function from Yanfly Keyboard Config within a plugin I've created. What I want to do is make my code run after this function runs but if I so much as alias the function it messes up the function and it doesn't run at all. Maybe I'm doing something wrong?
I was able to successfully alias another function within the plugin and add the keys to the list of actions when you select a button to bind it but this one keeps giving me problems.

This is what I'm trying to do, this function is called to determine what text shows up on the keys if they are in use. I would like my parameters to show up as the name that gets drawn on the keys.

This code below will make the text show up on the keys but ONLY these keys and not every other key that is normally drawn using the original function in Yanfly Keyboard config.

JavaScript:
    var Ritter_Window_KeyConfig = Window_KeyConfig.prototype.actionKey;
    Window_KeyConfig.prototype.actionKey = function(action) {
        Ritter_Window_KeyConfig.call(this,action);
        switch(action) {
            case Ritter.Params.togForButton[1]:
                return Ritter.Params.togForName;
                break;
            case Ritter.Params.togBackButton[1]:
                return Ritter.Params.togBackName;
                break;
            case Ritter.Params.useItemButton[1]:
                return Ritter.Params.useItemName;
                break;
        }
    };

If i do this below then no text will be drawn on any keys.

JavaScript:
    var Ritter_Window_KeyConfig = Window_KeyConfig.prototype.actionKey;
    Window_KeyConfig.prototype.actionKey = function(action) {
        Ritter_Window_KeyConfig.call(this,action);
    };

Hoping someone can help me figure out what it is I'm doing wrong here. :mrsatan:
Was the aliased function originally returning a value, when it was finished?
If so, it currently isn't returning anything, so that could be an issue. I don't have these plugins at hand to review, unfortunately

If this is the case, then when you call the aliased function, assign it's result to a variable.
Then at the end of your process that you added, return that value before the function closes.
As this plugin is one of yanflys free downloads I suppose posting the original function shouldn't hurt anything. It returns many values depending on the key which it is accessing. I was hoping to be able to return my own data after it writes the text for every button. The top code I posted does draw the text as I want it to on the proper keys but I just need it to also draw the text for every other button 😀

JavaScript:
Window_KeyConfig.prototype.actionKey = function(action) {
        switch(action) {
        case 'ok':
            return Yanfly.Param.KeyConfigOkKey;
            break;
        case 'escape':
            return Yanfly.Param.KeyConfigEscKey;
            break;
        case 'cancel':
            return Yanfly.Param.KeyConfigCancelKey;
            break;
        case 'menu':
            return Yanfly.Param.KeyConfigMenuKey;
            break;
        case 'shift':
            return Yanfly.Param.KeyConfigShiftKey;
            break;
        case 'pageup':
            return Yanfly.Param.KeyConfigPageUpKey;
            break;
        case 'pagedown':
            return Yanfly.Param.KeyConfigPageDnKey;
            break;
        case 'left':
            return Yanfly.Param.KeyConfigLeftKey;
            break;
        case 'up':
            return Yanfly.Param.KeyConfigUpKey;
            break;
        case 'right':
            return Yanfly.Param.KeyConfigRightKey;
            break;
        case 'down':
            return Yanfly.Param.KeyConfigDownKey;
            break;
    default:
      if (Imported.YEP_ButtonCommonEvents) {
        if (Yanfly.Param.BCEList[action]) {
          var id = Yanfly.Param.BCEList[action];
          var ev = $dataCommonEvents[id];
          return ev.configKey;
        }
      }
      return '';
      break;
        }
};

Edit:

So I just tried this and it seems to work, I'm not sure if this is proper though. Thanks for posting, it really helped clear up what was happening here, things just weren't clicking in my brain. :mrsatan:

JavaScript:
    var Ritter_Window_KeyConfig = Window_KeyConfig.prototype.actionKey;
    Window_KeyConfig.prototype.actionKey = function(action) {
       
        switch(action) {
            case Ritter.Params.togForButton[1]:
                return Ritter.Params.togForName;
                break;
            case Ritter.Params.togBackButton[1]:
                return Ritter.Params.togBackName;
                break;
            case Ritter.Params.useItemButton[1]:
                return Ritter.Params.useItemName;
                break;
            default:
                return Ritter_Window_KeyConfig.call(this,action);
                break;
        }
    };
It's fine to do it this way, you don't actually need the break statements now, though, bc whenever it reaches a return statement, the function exits. But outside of that yeah, it looks like the rest of the program wasn't getting that returned value it was expecting.

I've done that a bunch of times; aliased something and 'broke' everything, only to find that it was just the original returned value missing :b

Original thread: https://forums.rpgmakerweb.com/threads/trouble-aliasing-a-function-from-yanfly-keyboard-config.122103/