Hello All,
Forgive in advance my lack of knowledge on this subject, but I think my problem is a relatively simple one for someone more familiar with Javascript.
I have a wonderful virtual keyboard for use on a touch screen kiosk. This keyboard comes in the form of a Firefox plugin ( I can’t seem to figure out how to get Firebug to “see” a plugin…) which consist of nothing more then an overlay.xul file and an overlay.js file.
Everything in this keyboard works well except for the “Enter” key. It works for adding a new line, but doesn’t work for submitting forms and things like that.
What I really would like to do is have the Enter button simply emulate actually striking the enter key. For example you type you search into Google and hit enter, your search is executed. My goal in this is to have the button universally submit forms that are written to submit when enter is struck.
Here is the overlay.js file:
[CODE]/*
FxKeyboard
Version: 1.2
Author: Marko Zabreznik
Date: 22 Feb 2009
Purpose: Firefox Keyboard
*/
window.addEventListener(“load”, function() { FxKeyboard.startUp(); }, false);
var FxKeyboard = {
startUp: function()
{
var self = this;
// globals —————————————*/
this.shift = false;
this.caps = false;
this.focus;
this.capsbutton = document.getElementById(‘fxkeyboard_caps’);
this.shiftbutton = document.getElementById(‘fxkeyboard_shift’);
this.toolbar = document.getElementById(‘fxkeyboard_toolbar’);
// draw layout —————————————*/
osKeys = new Array (
‘1’,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’0′,’%’,’*’,’-‘,’ä’,-1,
‘q’,’w’,’e’,’r’,’t’,’z’,’u’,’i’,’o’,’p’,’š’,’đ’,’+’,’ß’,-1,
‘a’,’s’,’d’,’f’,’g’,’h’,’j’,’k’,’l’,’č’,’ć’,’ž’,’€’,’ö’,-1,
‘y’,’x’,’c’,’v’,’b’,’n’,’m’,’@’,’.’,’,’,’!’,’?’,’\’,’ü’);
var keyboard = document.getElementById(‘fxkeyboard_keyboard’);
var tempRow = document.createElement(“hbox”);var temp;
for ( var i in osKeys ) {
if (osKeys[i] == -1) {
tempRow.setAttribute(“flex”, ‘1’);
keyboard.appendChild(tempRow);
tempRow = document.createElement(“hbox”);
}
else {
tempRow.appendChild(this.addButton(osKeys[i].toUpperCase(),osKeys[i],osKeys[i].toUpperCase()));
}
}
tempRow.setAttribute(“flex”, ‘1’);
keyboard.appendChild(tempRow);
// on click —————————————*/
window.addEventListener(“DOMContentLoaded”, function(aEvent) {
var thebrowserget = gBrowser.getBrowserForDocument(aEvent.target);
if(thebrowserget)thebrowserget.addEventListener(“click”, function() { FxKeyboard.itemFocused(); }, false);
FxKeyboard.toggletoolbar(true);
}, true);
},
itemFocused: function () {
var focused = document.commandDispatcher.focusedElement;
if (focused && (focused.type == ‘text’ || focused.type == ‘textarea’ || focused.type == “password”)) {
// textarea found, open keyboard
this.focus = focused;
this.toggletoolbar(false);
}
else {
this.toggletoolbar(true);
}
},
toggletoolbar: function(set){
this.toolbar.collapsed = set;
},
buttonAction: function(button) {
if (this.shift) {
this.focus.value+=(button.action2);
this.doShift();
}
else
this.focus.value+=(button.action1);
},
addButton: function(name, action1, action2) {
tempButton = document.createElement(“button”);
tempButton.setAttribute(“label”, name);
tempButton.setAttribute(“tooltiptext”, name);
tempButton.setAttribute(“flex”, ‘1’);
tempButton.action1 = action1;
// simple test if it is a character
if (name.toLowerCase() !== name.toUpperCase()) tempButton.style.fontWeight=”bold”
tempButton.style.minWidth=”40px”
tempButton.style.height=”40px”
tempButton.action2 = action2;
tempButton.setAttribute(“oncommand”, ‘FxKeyboard.buttonAction(this)’);
return tempButton;
},
doShift: function (){
if (this.caps) return;
this.shift = !this.shift;
this.shiftbutton.style.color = (this.shift) ? “#ff0000” : ‘#000000’;
},
doCaps: function (){
if (this.caps) {
this.shift = this.caps = false;
this.capsbutton.style.color = this.shiftbutton.style.color = ‘#000000’;
}
else {
this.shift = this.caps = true;
this.capsbutton.style.color = this.shiftbutton.style.color = ‘#ff0000’;
}
},
doBackspace: function (){
this.focus.value = this.focus.value.slice(0, -1);
},
doClear: function (){
this.focus.value=”;
},
doEnter: function (){
this.focus.value+=’n’;
},
doSpace: function (){
this.focus.value+=’ ‘;
}
}
// END FxKeyboard
If anyone can help I thank you very much in advance. If no one has any ideas, even a point in the right direction would be greatly appreciated.