GM 1.7.1 – gmshortcutkeys missing

I enjoy using the shortcut keys provided by a simple Javascript addition to gm when using IE to allow me to do CTRL-SHIFT-A to add links quickly and also the same commands can be used to quickly bold or italic text. This features was in 1.3.0 and was deleted from 1.3.1 by accident by the previous maintainers. I posted a blog entry http://web.petefinnigan.com/weblog/archives/00000008.htm at the time about it.

The same code is still missing in 1.7.1 but the text describing how to use it is still there. To add this back go to gm-library.cgi lines 244 to 260 br]

Code:

date.setTime(date.getTime() – skew);
}
//–>
</SCRIPT>
#;
$gmheadtagtwo = $gmheadtag;$gmheadtag .= qq#
</HEAD>

<body>#;

$gmheadtagtwo .= qq#
</HEAD>

<body>#;

change these lines to:

Code:

date.setTime(date.getTime() – skew);
}
#;
$gmheadtagtwo = $gmheadtag;$gmheadtag .= qq#
//–>
</SCRIPT>

</HEAD>

<body>#;

$gmheadtagtwo .= qq#
function gmshortcutkeys() {
if ((parseInt(navigator.appVersion) >= 4) && (navigator.appName == “Microsoft Internet Explorer”)) {
if (event.ctrlKey != true) return;
gmselection = document.selection.createRange().text;
if (window.event.keyCode == 1) {
gminsertlink = prompt(“What do you want to link to?”, “http://”)
if (gminsertlink == null) return;
document.selection.createRange().text = ‘<a href=”‘ + gminsertlink + ‘”>’ + gmselection + ‘</a>’;
return;
}
if (window.event.keyCode == 2) {
document.selection.createRange().text = ‘<span style=”font-weight:bold;”>’ + gmselection + ‘</span>’;
return;
}
if (window.event.keyCode == 9) {
document.selection.createRange().text = ‘<span style=”font-style:italic;”>’ + gmselection + ‘</span>’;
return;
}
if (window.event.keyCode == 21) {
document.selection.createRange().text = ‘<span style=”text-decoration:underline;”>’ + gmselection + ‘</span>’;
return;
}
}
}

//–>
</SCRIPT>

</HEAD>

<body onKeyPress=”gmshortcutkeys();”>#;

My apologies on this Pete. I know you had mentioned this before 1.6.1 came out, and it fell off my plate. I will make sure this is in 1.7.2.

Btw, I was thinking of using ‘thumbs up’ icon for fixed issues, and ‘thumbs down’ for open, I just wanted an easy way to see if an issue was fixed or not.

Plus, I wonder if this could be made to work for all platforms, I’ll have to experiment a little.

I’ve modified the gm-library.cgi with the new lines on GM v1.3.1 but no success nothing happen when I try the shortkeys… I also put the cookies fonction ON in the config.
Any idea why isn’t work?

have a look at http://web.petefinnigan.com/greymatter_mods.htm – this page includes my gm-library.cgi saved as dot txt, download this file and replace your gm-library.cgi with it. Save your own file first.

I finally checked in your changes to CVS, thanks for your patience.

I did some research and it looks like javascript keystroke compatibility between browsers and OS is a thorny issue. I am hoping to play with the code and get a universal feature going, but for now, the old functionality has been restored for all you IE users.

While I was porting this to be generic for both Windows/Mac/All Browsers, I ran across discussions about changing the key mappings like this. Some people really don’t like it. I am wondering if this should be an option that is enabled, or if buttons (such as on this forum) would work?

I can see the appeal of just using key shortcuts, but if they interfere with someone’s existing key mappings, I am concerned. I wonder if that is why it was removed initially?

On a side note, I found that with accesskey attribute, you can do key assignments almost universally. However, IE is being difficult.