MozillaZine

keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
avada
 
Posts: 1847
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted January 13th, 2014, 7:20 am

Zoolcar9 wrote:
avada wrote:Anyone have a clue how to get it work today with the Session Manager addon?

Try

Code: Select all
document.getElementById("cmd_session_manager_load").doCommand();
document.getElementById("cmd_session_manager_save_window").doCommand();
document.getElementById("cmd_session_manager_save").doCommand();
document.getElementById("cmd_session_manager_delete").doCommand(); 


Thanks!

(Now I only have to find a shortcut that makes sense because altgr+L refuses to work.)

Caspid

User avatar
 
Posts: 580
Joined: December 18th, 2005, 4:01 pm

Post Posted January 17th, 2014, 11:04 am

Is there a way to switch back to the last-selected tab (without altering the about:config pref)?
"Know what I pray for? The strength to change what I can, the inability to accept what I can't, and the incapacity to tell the difference." -Calvin

pintassilgo
 
Posts: 163
Joined: August 30th, 2013, 3:50 pm

Post Posted January 17th, 2014, 8:51 pm

Caspid wrote:Is there a way to switch back to the last-selected tab (without altering the about:config pref)?


Code: Select all
var tab = gBrowser.selectedTab;
var tabs = tab.parentNode.childNodes;
var index = 0;
var last  = 0;
for (var i = 0; i < tabs.length; i++) {
  var s = tabs[i].getAttribute('lastselected');
  if (s && s > last && tabs[i] != tab) {
    index = i;
    last = s;
  }
}
gBrowser.selectedTab = tabs[index];


(code from FLST extension)

Caspid

User avatar
 
Posts: 580
Joined: December 18th, 2005, 4:01 pm

Post Posted January 18th, 2014, 6:46 pm

pintassilgo wrote:
Caspid wrote:Is there a way to switch back to the last-selected tab (without altering the about:config pref)?


Code: Select all
var tab = gBrowser.selectedTab;
var tabs = tab.parentNode.childNodes;
var index = 0;
var last  = 0;
for (var i = 0; i < tabs.length; i++) {
  var s = tabs[i].getAttribute('lastselected');
  if (s && s > last && tabs[i] != tab) {
    index = i;
    last = s;
  }
}
gBrowser.selectedTab = tabs[index];


(code from FLST extension)

Thanks, but the behavior isn't quite what's expected - it jumps to the first tab for me.
"Know what I pray for? The strength to change what I can, the inability to accept what I can't, and the incapacity to tell the difference." -Calvin

mward
 
Posts: 1
Joined: January 24th, 2014, 4:08 am

Post Posted January 24th, 2014, 4:34 am

I had problems getting keyconfig installed in Thunderbird 24.2.0: It simply didn't appear in the list of add-ons!

In the end, I installed it in Firefox, and then copied the keyconfig@dorando.xpi file from my Firefox extensions directory to the Thunderbird extensions directory: next time I started up Thunderbird it asked if I wanted to install keyconfig.

I have now switched from kmail to Thunderbird (due to too many problems with kmail: searching not working, email completion from address book not working, sometimes emails are not visible...)

With keyconfig I have got Thunderbird working the way I want: but there is one feature I miss. With kmail I can hit "m" and get a menu of all folders: clicking on a folder moves the email to that folder.

With Thunderbird I have to right-click and navigate through several layers of menus to move a message to a folder (or drag and drop, which is also fiddly)

I don't mind if the list of folders is "hard-wired" into the program: in fact, it would be really useful to be able to define a key which brings up a user-defined menu of commands!

dorando
 
Posts: 1203
Joined: January 9th, 2004, 9:57 am

Post Posted January 24th, 2014, 9:42 am

Thanks to everyone answering questions.

chirpy_7 wrote:For about 1 week or 2 I've noticed that occasionally (and so far unpredictably) the single-stroke keyconfig keys stop working (until I restart FF).
Sadly no idea what could cause that, nor how to diagnose it. Note that the Application does the handling, not keyconfig.

OlegYch wrote:i have a problem with it though - if i add or change shorctut to e.g. ctrl-alt-z and switch keyboard layout to russian the shortcut stops working (unless i also add ctrl-alt-я shortcut - я is at the same key as z on russian keyboards)
can this be fixed?
Since the application does all shortcut handling, the only way would be to add multiple shortcuts.

Note that the application actually uses the ASCII/Latin equivalents if either Ctrl or Alt is pressed (but not if both are pressed) and actually uses it as the default for Ctrl.
OlegYch wrote:When I add ctrl-alt-я shortcut all hell breaks loose - e.g. firefox starts trying to bookmark current page when i press tab or escape.
Doesn't seem to happen for me (Russian Firefox with Russian layout), maybe another extension interferes?

Miccovin wrote:is it possible to deactivate a key at a special site?

For example lets get the simple "script" to scroll up 1 line:
Code: Select all
goDoCommand('cmd_scrollLineUp');

But the key for this should be automatically deactivated on a special site, maybe on forums.mozillazine.org.
Try
Code: Select all
if(content.location.host != "forums.mozillazine.org") {
 
goDoCommand('cmd_scrollLineUp');
https://developer.mozilla.org/docs/Web/API/Location

sashabe wrote:I use Checkvist service for tasks, and it allows you to manipulate the tasks from keyboard.
Currently I use this code to load Checkvist page into a sidebar and then try to focus its contents, but focus doesn't seem to settle in the right place:
Code: Select all
var sidebar_box = document.getElementById('sidebar-box');
if(sidebar_box.hidden) {openWebPanel("Checkvist","http://checkvist.com/iframe.html");
gURLBar.focus();
for (var i = 0; i<4; i++) {
    window.setTimeout(function() {
 commandDispatcher.advanceFocus();
}, 200);
}
}
else {toggleSidebar();}
Try
Code: Select all
var sidebar_box document.getElementById('sidebar-box');
if(
sidebar_box.hidden) {
 
openWebPanel("Checkvist","http://checkvist.com/iframe.html");

 var 
sidebar document.getElementById("sidebar");

 
sidebar.addEventListener("load", function tempFunction(event) {
  
sidebar.removeEventListener("load"tempFunctiontrue);

  var 
webPanelsBrowser event.target.getElementById("web-panels-browser");
  
webPanelsBrowser.addEventListener("load", function tempFunction(event) {
   
webPanelsBrowser.removeEventListener("load"tempFunctiontrue);

   
event.target.defaultView.setTimeout(function() {
    
gURLBar.focus();
    for (var 
0i<4i++) {
     
commandDispatcher.advanceFocus();
    }
   }, 
0);

  }, 
true);
 }, 
true);
} else {
 
toggleSidebar();

bege wrote:
dorando wrote:Try
Code: Select all
ChangeLanguage({ target: { value"en-US" }, __noSuchMethod__: function() { } }); 
It doesn't work here :roll:
What can I try to make it work?

Windows 7 Professional 64 bit
FF 23.0.1
Try
Code: Select all
var dictionary "en-US";

var 
Cc Components.classes; var Ci Components.interfaces;

Cc['@mozilla.org/spellchecker/engine;1'].getService(Ci.mozISpellCheckingEngine).dictionary dictionary;

var 
nsIContentPrefService2 Cc["@mozilla.org/content-pref/service;1"].getService(Ci.nsIContentPrefService2);
var 
target document.commandDispatcher.focusedWindow;
if(
target == windowtarget content;
var 
loadContext target.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsILoadContext);
nsIContentPrefService2.set(target.location"spellcheck.lang"dictionaryloadContext);

Services.prefs.setCharPref("spellchecker.dictionary"dictionary); 
Note that spell check settings are remembered per site since Bug 678842.

ddong wrote:Hello, i'm trying to change the next/previous tab group keyboard shortcut. So i ended up downloading this extension. However, even after long searching, i couldn't find the code related to these actions.
You can't change those shortcuts (due to the way they are defined/handled), but for new shortcuts try:
Code: Select all
TabView._initFrame(function() {
 var 
groupItems TabView._window.GroupItems;
 var 
tabItem groupItems.getNextGroupItemTab(true);
 if (!
tabItem)
  return;

 if (
gBrowser.selectedTab.pinned)
  
groupItems.updateActiveGroupItemAndTabBar(tabItem, {dontSetActiveTabInGrouptrue});
 else
  
gBrowser.selectedTab tabItem.tab;
}); 
and
Code: Select all
TabView._initFrame(function() {
 var 
groupItems TabView._window.GroupItems;
 var 
tabItem groupItems.getNextGroupItemTab(false);
 if (!
tabItem)
  return;

 if (
gBrowser.selectedTab.pinned)
  
groupItems.updateActiveGroupItemAndTabBar(tabItem, {dontSetActiveTabInGrouptrue});
 else
  
gBrowser.selectedTab tabItem.tab;
}); 
which matches the original code.

Alternatively you can try to invoke the original handler with:
Code: Select all
var utils window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);

utils.sendKeyEvent("keypress"0"`".charCodeAt(0), Event.CONTROL_MASK); 
and
Code: Select all
var utils window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);

utils.sendKeyEvent("keypress"0"`".charCodeAt(0), Event.CONTROL_MASK Event.SHIFT_MASK); 

Allasso wrote:I am using Mac, I have observed that when changing to a keybinding which uses the Alt key, when typed into the textbox, the character is translated into a special character. So if I type say, "Alt + S", it enters only ß (does not show Alt symbol). I would expect this behavior in the textbox, since that is what Macs do by default when using the Alt key. However, apparently because of this, keyconfig is not recognizing it as "Alt + S", and so there is no mapping done, and the command does not work. I can put the code <key key="S" modifiers="alt" command="some_command"/> into an overlay and it will work, so I know that that combination is valid on Mac. It is just that I cannot assign it to that using keyconfig.

If, however, the Alt key is combined with another modifier, eg, "Alt + Cmd + S", then "<Alt symbol><Cmd symbol>ß" appears in the textbox. I can assign it, and it will work, however, from then on, "<Alt symbol><Cmd symbol>ß" (with the special character) is what will always appear in the keybinding list.
Sounds like Bug 308565 - event.altKey is always false for onkeypress on Mac (I wonder if getModifierState has the same behavior). Since Alt+S works for the overlay, changing the modifier through about:config for a shortcut should also work.
Allasso wrote:I get this error when I open keyconfig in FF 26:

JavaScript error: chrome://keyconfig/content/keyconfig.js, line 419: props is undefined
JavaScript error: chrome://keyconfig/content/keyconfig.js, line 424: props is undefined
Thanks for reporting, will be fixed in the next release.

mantra wrote:may i know where can find the list of command/id , the code ?
Check the Mozilla Developer Network or Mozilla Cross-Reference or use DOM Inspector or the Web Console.

Springtime wrote:Also, as this is the right thread for it: I'd like to suggest the ability in Firefox/keyconfig to add mnemonic keyboard shortcuts.

For example: by creating the shortcut "p,i,n" (p followed by i followed by n) one could toggle Pinning a tab. It's an incredibly useful feature Opera 12 has as a side-effect of being able to manually enter shortcut commands by typing them out. Naturally they are disabled while a textbox is focused.
You might be interested in KeySnail. With keyconfig you could try something like:
Code: Select all
var buffer "p";
XULBrowserWindow.statusTextField.label buffer;

window.addEventListener("keypress", function tempFunction(event) {

 var 
modifiers = ["Alt","Control","Meta","Shift","OS"]
 .
filter(function(valiobj){ return event.getModifierState(val); }).join(" ");

 if(
modifiers)
  
buffer null;
 else
  
buffer += String.fromCharCode(event.charCode)

 var 
finished false;

 switch(
buffer) {
  case 
"pi" event.stopPropagation(); event.preventDefault(); break;
  case 
"pin"event.stopPropagation(); event.preventDefault();

   if(
gBrowser.selectedTab.pinned)
    
gBrowser.unpinTab(gBrowser.selectedTab);
   else
    
gBrowser.pinTab(gBrowser.selectedTab);

   
finished true;

   break;
  default:
   
finished true;
 }

 if(
finished) {
  
window.removeEventListener("keypress"tempFunctiontrue);
  
XULBrowserWindow.statusText null;
  
XULBrowserWindow.updateStatusField();
 } else {
  
XULBrowserWindow.statusTextField.label buffer;
 }

}, 
true); 
and assign p to it.

avada wrote:Anyone knows a workaround for the super annoying "alt gr" (or "ctrl+alt", apparently they're the same) bug?
I can use some characters like "H" with this prefix without issue. Others get the secondary character for that key, so they don't work in a textfield. (I guess there's no way around this.) "i" and "j" changes to "í" with this prefix. Which is a different key on the keyboard, so I can't use them.
You could try Customizable Shortcuts, Custom Buttons, or other Add-ons using event listeners to handle the shortcuts directly (keyconfig doesn't handle shortcuts at all, the Application does it).
avada wrote:But with "L" I get nothing I get the "Ł" character for the hotkey but it doesn't react at all. It works for altgr+"k" though which brings up the same character in the settings.
Using Hungarian Keyboard Layout or Hungarian 101-key Keyboard Layout both seem to work for me (they do appear the same because they get converted to uppercase before displaying/handling).

Caspid wrote:Is there a way to switch back to the last-selected tab (without altering the about:config pref)?
Try
Code: Select all
var lastAccessed 0;
var 
lastTab gBrowser.selectedTab;

for(
tab of gBrowser.visibleTabs) {
 if(
tab.lastAccessed lastAccessed && gBrowser.selectedTab != tab) {
  
lastAccessed tab.lastAccessed;
  
lastTab tab;
 }
}

gBrowser.selectedTab lastTab

mward wrote:but there is one feature I miss. With kmail I can hit "m" and get a menu of all folders: clicking on a folder moves the email to that folder.
Try to Add a new key containing:
Code: Select all
var allFolders MailServices.accounts.allFolders.enumerate();
var 
folders = [];
while(
allFolders.hasMoreElements()) {
 var 
folder allFolders.getNext().QueryInterface(Components.interfaces.nsIMsgFolder);
 if(
folder.canFileMessages)
  
folders.push(folder);
}
folders.sort(function(ab) {
 return (
a.prettiestName " - " a.parent.prettiestName) > (b.prettiestName " - " b.parent.prettiestName);
});

var 
tempMenu document.createElement("menupopup");

for(
folder of folders) {
 var 
menuitem document.createElement("menuitem");
 
menuitem.setAttribute("label"folder.prettiestName " - " folder.parent.prettiestName);
 
menuitem.setAttribute("class""folderMenuItem menuitem-iconic");
 
menuitem.setAttribute("SpecialFolder"getSpecialFolderString(folder));
 
menuitem.setAttribute("IsSecure"folder.server.isSecure);
 
menuitem.setAttribute("ServerType"folder.server.type);
 
menuitem._folder folder;
 
tempMenu.appendChild(menuitem);
}

document.documentElement.appendChild(tempMenu);
tempMenu.openPopup(null"after_start"00truefalseevent);

var 
listener = {
 
handleEvent: function(event) {
  switch(
event.type) {
   case 
"command":
    
MsgMoveMessage(event.target._folder)
   break;

   case 
"popuphiding":
    if(
event.eventPhase != event.AT_TARGET)
     return;
   break;
  }

  
tempMenu.removeEventListener("command"listenerfalse);
  
tempMenu.removeEventListener("popuphiding"listenerfalse);
  
document.documentElement.removeChild(tempMenu);
 }
}

tempMenu.addEventListener("command"listenerfalse);
tempMenu.addEventListener("popuphiding"listenerfalse); 
Support mozilla.dorando.at through donations/contributions.

bege
 
Posts: 119
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted January 24th, 2014, 9:50 pm

dorando wrote:
bege wrote:
dorando wrote:Try
Code: Select all
ChangeLanguage({ target: { value: "en-US" }, __noSuchMethod__: function() { } }); 
It doesn't work here :roll:
What can I try to make it work?

Windows 7 Professional 64 bit
FF 23.0.1
Try
Code: Select all
var dictionary = "en-US";

var Cc = Components.classes; var Ci = Components.interfaces;

Cc['@mozilla.org/spellchecker/engine;1'].getService(Ci.mozISpellCheckingEngine).dictionary = dictionary;

var nsIContentPrefService2 = Cc["@mozilla.org/content-pref/service;1"].getService(Ci.nsIContentPrefService2);
var target = document.commandDispatcher.focusedWindow;
if(
target == window) target = content;
var loadContext = target.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsILoadContext);
nsIContentPrefService2.set(target.location, "spellcheck.lang", dictionary, loadContext);

Services.prefs.setCharPref("spellchecker.dictionary", dictionary); 
Note that spell check settings are remembered per site since Bug 678842.

Works perfect! Thank you very much!

avada
 
Posts: 1847
Joined: February 10th, 2008, 6:30 am
Location: Hungary

Post Posted January 26th, 2014, 11:06 am

Can I define a hotkey for enabling disabling an addon?
It'd be useful for some addons that don't need restart, but I also don't want to run them all the time.

Caspid

User avatar
 
Posts: 580
Joined: December 18th, 2005, 4:01 pm

Post Posted January 26th, 2014, 11:15 am

Amazing, you're a wizard. Thanks!
"Know what I pray for? The strength to change what I can, the inability to accept what I can't, and the incapacity to tell the difference." -Calvin

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted January 26th, 2014, 2:33 pm

avada wrote:Can I define a hotkey for enabling disabling an addon?
It'd be useful for some addons that don't need restart, but I also don't want to run them all the time.

Same method with viewtopic.php?p=13221221#p13221221
My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

bege
 
Posts: 119
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted February 10th, 2014, 6:49 am

Hi,

I want to be able to close the attachment reminder in the Thunderbird compose window with a shortcut.
Oncommand for the close button is
Code: Select all
document.getBindingParent(this).close();
, but that doesn't work with keyconfig.
Class is
Code: Select all
messageCloseButton tabbable
, there ist no id for that button.

What must the code for this shortcut be?
Thank you.

Springtime
 
Posts: 68
Joined: November 8th, 2013, 8:59 pm

Post Posted February 12th, 2014, 10:44 pm

Quick question: is there a way to set two shortcuts for the one command?

On Windows I can't seem to use the shortcut Ctrl+Alt+Left/Right arrow to switch between left/right tabs anyone. As I have an alternative shortcut set-up which does the same thing I'm wondering if keyconfig could use two shortcuts for the same command, just to save having duplicates.

Edit: I'm also experiencing an issue where I've set "Ctrl+Shift+I" for one command, yet Firefox is using that command for the web inspector panel popup, even though Keyconfig gives no warning about it. Any idea how to disable the default?

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted February 13th, 2014, 9:30 am

Springtime wrote:Quick question: is there a way to set two shortcuts for the one command?

Of course. Just copy the code and create a new key.

Springtime wrote:On Windows I can't seem to use the shortcut Ctrl+Alt+Left/Right arrow to switch between left/right tabs anyone.

Use Ctrl+Tab/Ctrl+Shift+Tab or Ctrl+PageDown/Ctrl+PageUp to switch between tabs.

Springtime wrote:I'm also experiencing an issue where I've set "Ctrl+Shift+I" for one command, yet irefox is using that command for the web inspector panel popup, even though Keyconfig gives no warning about it. Any idea how to disable the default?

Select 'Toggle Tools' key in keyconfig and click 'Disable' button.
My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

Springtime
 
Posts: 68
Joined: November 8th, 2013, 8:59 pm

Post Posted February 13th, 2014, 9:37 am

Thanks, shortcuts work now. I guess a couple duplicates won't hurt ;)

Leopoldus
 
Posts: 353
Joined: April 8th, 2008, 4:29 am

Post Posted February 22nd, 2014, 4:18 pm

Hi!

Is there any ready-made code for a hotkey to toggle on/off HTML view? There was an add-on HTML View toggle, but it has stop working many TB versions and many years ago.
Thanks!

P.S.
Is there any option to search trough the specific topic hear at mozillazine.org forum, eg this topic, which has as many as 180 pages? Many other forum engines let display the whole topic at the single (very long) page, say, as "print view", but here print view displays the current page of the topic only. :(
Or may be there is some other place, where one can see all already existing codes for KeyConfig in order not to ask for the same solutions again and again...

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 4 guests