Opera Tab Override User JS

A few days ago I released a WordPress plugin that overrides the default tab keypress action. This means when you press tab it inserts a tab character rather than moving focus from one field to another. I made a few modificaitons to this script in order to turn it into an Opera UserJS application. To use Tab Override for Opera, copy the following code and place it in a file called taboverride.js in your UserJS file:

function operaTab(e)
	if (e.keyCode == 9)
		var obj = e.target;
		obj.selection = document.selection.createRange();
		obj.selection.text = String.fromCharCode(9);
	return false;
function tablistener(){
	var textareaArr = document.getElementsByTagName('textarea');
	for( var i in textareaArr )
		textareaArr[i].addEventListener('keypress', operaTab, true);

Using UserJS
If you don’t have UserJS enabled or are unsure if it is enabled, here’s how you do it:

  • In Opera, on the toolbar click Tools -> Preferences...
  • Click the Advanced tab and select the Content submenu.
  • Make sure Javascript is enabled and click the JavaScript Options... button.
  • Under User JavaScript Files should be the path to your userjs file. The default is C:\Program Files\Opera\userjs.
  • If the path is not set, set it to the default. All you need to do to activate a User JS file is add it to the specified folder.

Some Issues with the script

The script will only work on textarea fields. This is intentional, as in other fields the default tab action is preferable. If you want to override all tabs, modify the line var textareaArr = document.getElementsByTagName('textarea'); to read var textareaArr = document.getElementsByTagName('form');

The script won’t work on some platforms due to interfering scripts. I’ve experienced this on some but not all vBulletin forums. I believe it is possible to override these scripts, but I have not yet figured out how.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>