Penny-Arcade Forums Tab-Index Fix

Temp fix for tabbing issue on the forums

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Penny-Arcade Forums Tab-Index Fix
// @namespace    https://greasyfork.org/en/users/162009-delmain
// @author       delmain
// @version      0.3.0
// @description  Temp fix for tabbing issue on the forums
// @match        https://forums.penny-arcade.com/discussion/*
// @match        https://forums.penny-arcade.com/messages/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    $(document).ready(function() {
        $('.TextBoxWrapper').on('keydown', 'textarea', moveToSubmitHandler);
    });

    $(document).on('EditCommentFormLoaded', function(event, element) {
        $(element).find('.TextBoxWrapper').on('keydown', 'textarea', moveToSubmitHandler);
    });

    function moveToSubmitHandler(e)
    {
        var target = e.target;
        var keyCode = e.keyCode || e.which;

        if (keyCode == 9) {
            e.preventDefault();
            var tg = $(target).closest('form');
            var bu = tg.find('#Form_PostComment,#Form_SendMessage,#Form_SaveComment');
            bu.focus();
        }
    }
})();