drummerSupport
drummerSupport copied to clipboard
Keyboard issues
@papascott -- your attention please. :smile:
I just did some work on keyboard handling in Drummer. Here's some text from a recent change note.
One more thing -- to Scott Hanson -- I added a mapping for cmd-/. Maybe it now works on your (German) keyboard. If so I may have tripped over a fix for a lot of those problems. Using the keypress library.
Please try pressing cmd-/ on your German keyboard. Let's see if it works.
I'm currently on a family visit in Minnesota, but I saw my name in the change notes and tried it out. No, cmd-/ still doesn't work.
My homemade shortcut (that switches to US keyboard then sends cmd-/) still works, but now I see an error in the console.
code.js:4331 Uncaught ReferenceError: runScript is not defined
at on_keydown (code.js:4331)
at m (keypress.js:4)
at Z (keypress.js:10)
at ca (keypress.js:11)
at C (keypress.js:13)
at HTMLBodyElement.<anonymous> (keypress.js:21)
The script does run as expected, though.
Oh sorry. I broke that.
Fixed. Try again.
I was unclear... the console error appeared with the US keyboard activated, not with the German keyboard.
Current situation, I've selected the line "twitter.getUserInfo ("davewiner").ctFollowers": cmd-/ with German keyboard: No reaction, no message in the console
cmd-/ with US keyboard: Script runs as expected, console output
runScriptText: processedScriptText == (async function () {await processRunCursorScriptResult((await twitter.getUserInfo('davewiner')).ctFollowers, 4);})()
code.js:1449 servercall: url == http://drummer.scripting.com/getuserinfoforverb?screenname=davewiner&oauth_token=5502892-bgBZeDmBbTCyTunuDnJhFaUa77tj9DPJr0UgqcuKQ1&oauth_token_secret=celCNEGf9hxUBY8bTNwgzCJyHFifsPWN5sTVImfTsoxwc, secs == 0.24
verbs.js:312 data == {
"screenname": "davewiner",
"name": "Dave Winer",
"id": "3839",
"description": "I create new media types for fun. Developer of outliners, blogging tools, RSS aggregators, podcasting.",
"location": "Woodstock, NY",
"whenCreated": "Sat, 05 Aug 2006 23:04:08 GMT",
"ctFollowers": 66705,
"ctFollowed": 3904,
"ctFavorites": 18153,
"ctTweets": 196023,
"urlProfileImage": "http://pbs.twimg.com/profile_images/1398806004528263168/2SXipvrt_normal.jpg"
}
code.js:916 saveThisTab: f == test.opml, secs == 0.056, secs since interact == 0.558
So no more error 😄
You weren't unclear -- I read it too fast. Sorry. I went back and fixed my comment.
I've done a bit of quick research to try to figure out what's happening. I found this article: Why Keyboard Shortcuts don't work on non-US Layouts and how Devs could fix it. It doesn't mention keypress.js specifically, but it does explain why shortcuts using symbol keys aren't working for me on the German keyboard.
Maybe the suggestion there under "Simple Workarounds" to define alternate alphanumeric keys for cmd-symbol keys would be an acceptable solution for Drummer (or Concord or wherever these keys are defined).
@papascott -- I read the article.
Here's the deal -- keyboard support in Drummer is kind of disjointed. There are two sets of keys:
-
Ones we have to "steal" from the browser, like Cmd-F, Cmd-G, Cmd-period and Cmd-comma. If you do the key mapping the normal way, the browser catches them. But if you use keypress.js, for some reason, due to some cleverness, you get control of them. I'll include below the object that configures keypress.js for Drummer. It's this special ability that made me think it might be possible to use it to get control of Cmd-/. I still think it might be possible.
-
Most of the other keystrokes are handled by Concord, and I have that code set up so it would be pretty easy to let the user specify the mappings. The core routine is concordMetaizeKeystroke. I think it should be self-explanatory. I could definitely see allowing this to be overridden, esp since Drummer has a built in scripting capability and there is code you can run at startup.
Here's the structure Drummer uses to initialize keypress.js.
myCombos = [
{ //cmd-comma to expand
"keys": "meta ,",
"is_ordered": true,
"on_keydown": function (ev) {
opExpand ();
event.stopPropagation ();
event.preventDefault ();
return (false);
}
},
{ //cmd-period to collapse
"keys": "meta .",
"is_ordered": true,
"on_keydown": function (ev) {
opCollapse ();
event.stopPropagation ();
event.preventDefault ();
return (false);
}
},
{ //cmd-f to find
"keys": "meta f",
"is_ordered": true,
"on_keydown": function (ev) {
opFindCommand ();
event.stopPropagation ();
event.preventDefault ();
return (false);
}
},
{ //cmd-g to find-again
"keys": "meta g",
"is_ordered": true,
"on_keydown": function (ev) {
console.log ("find again");
opFindAgainCommand ();
event.stopPropagation ();
event.preventDefault ();
return (false);
}
},
{ //cmd-/ to run a script
"keys": "meta /",
"is_ordered": true,
"on_keydown": function (ev) {
runCursorScript ();
event.stopPropagation ();
event.preventDefault ();
return (false);
}
}
];
I tried setting up a test page with keypress.js with both your parameters and some of my own, and I was not able to get it to recognize cmd-/ (or other symbols with different locations) on the German keyboard layout. I'm not sure keypress.js can do it... I think its looking for physical key presses, and the German layout has no physical slash key (the slash is on the 7 key). keypress.js also hasn't been updated since 2018 and has some open issues involving international layouts.
I'll happily write up my workaround for anyone else who wants to use Drummer on a non-US keyboard layout.
@papascott -- that would be most welcome.
Where are we going to publish those kinds of docs?
We should use the outliner. Maybe a directory of topics?
I would suggest to start, write it up in a public outline on your account, and post a link here.
Then I'll see what I can do on my end.
I wrote this up in a public outline. I included a couple of screenshots as inlineImages, I hope that works out!
Update: Corrected the link to the outline
Looking for a place to leave this tip -- hope this is ok. If you find that Cmd-\ shortcut (comment out a node) is not working, check and see if another utility is stealing it. In my case it was 1Password, which uses Cmd-\ as the default global shortcut for the "fill login" command.