Not sure if i'm the only person with slippery digits here, but "ctrl+w" for kill is especially dangerous considering it's proximity to "ctl+e" and "ctrl+s." I can't tell you how many times i've accidentally smacked this... any ideas on how to change shortcut keys?
-
Is it possible to change Pure Data's shortcut keys?
-
@lilsquiddy I don't think you can..... unsure though..... it might be possible in the tcl/tk code.
Disabling or re-patching the w key would probably cause you more problems (with windows and other programs)... but if you don't use ctrl-w anywhere else you could repatch the combination with "autohotkey"....... https://autohotkey.com/ You might find that Pd still uses it at the same time though..... again, I am unsure......
You could save this (below) to a file on your desktop........ and always open it and resave it with the name of the patch you are starting on (instead of opening a "new" patch)......... i.e. put it I all of your patches.
Pd will then ask if you really want to close any Pd windows, even if you use "ctrl-w".......
David.
-
Ya of course. I changed some of mine and added some more. You should use a gui plugin however. Tcl/tk is pretty straightforward though.
Almost all the bindings are in one file, pd_bindings.tcl - you can edit that file, but i'd suggest copying the proc (function) that holds the hotkeys you want to change into a new file as a gui plugin.
tk 8.4's docs for the bind command
or you could use 8.6's if you have one of danomatika's versions, or just because that page is formatted better...
The only difficult thing with hotkeys is making sure someone else's gui plugin doesn't overwrite the proc you just made/overwrote.
If you're making a new hotkey and new behavior, finding what to bind to, and where to put the bind call can take a little thought, but its still usually simple.
-
I had the same question as OP, and followed @monetus hints. Disclosure: I am a total copy/paste coder, doing it reluctantly. What I found was simply writing the following and saving it as myplugin-plugin.tcl in a Pd standard path, got it working:
# removes ctrl/cmd+w for closing window bind all <$::modifier-Key-w> {} # adds ctrl/cmd+y for putting a vslider bind all <$::modifier-Key-y> {menu_send %W vslider} # adds pressing "n" for making a new object bind all <Key-n> {menu_send_float %W obj 0}
It felt kind of dirty not defining any proc or namespace (wouldn't know how to do that correctly). Can anyone chime in on this being an ok way of solving the problem, or if there is a more by-the-books way? I guess there are a couple of users ending upp here trying to configure shortcuts/hotkeys.
-
is there a way to use this to put a specific object ?
-
@youaresound said:
is there a way to use this to put a specific object ?
Yes, but I don't know how! The theory is to fill an empty object with text (through the script), to turn it into another object, for example writing "bng" in an object turns it into a bang. It is done that way in another plugin example, quickbindings, available here. Unfortunately, that plugin doesn't check if you are already in an object writing when you invoke the shortcut, so its is kind of broken. Check it out to get an idea of the theory of filling an empty object wih text through a script.
Someone more knowledgeable should seriously chime in here…
-
so, the way you have used the bind command is perfectly fine, I was only suggesting a proc if you wanted to be able to toggle the hotkeys back and forth while pd is running.
And yes, you can use tcl to send pd messages and create objects. For the gui objects, the menu_send and menu_send_float commands are all you need to make sure bind is triggering. If you wanted to make specific objects or abstractions be bound to a hotkey, you need to create the obj then trick pd into thinking you typed something in. You do this with the pdsend command.
pdsend "$mytoplevel key 1 $keynum 0"
look at my github, the rename_obj proc. also look at the embedded button bar plugin buried in the pdsite.
-
@Monetus Thanks for the assistance! Your answers have been great, thorough and pedagogical, but in the end I'm too bad a coder to set it up. I couldn't get your last example snippet working, and couldn't mentally parse the example plugins you referred to either. So I have two questions, which is of the really humble "please help me out" variety:
Given the bare bones shortcut plugin I posted above, how would you add a shortcut to (for example) a metro object set to 100ms?
I also really want to have single keypresses (no modifier key) as shortcuts for creating objects. In the bare bones plugin above I assigned "N" to create an empty object. Problem is, as soon as I have my text cursor in an object typing, hitting "N" creates a new object, which is not my intention. How do I check for standing in an object typing, to in that case disable that single keypress shortcut?
As an appendix to that, one of the pd example plugins, quickbinings-plugin.tcl, defaults to "R" creating a recieve , and "O" creating an osc. Trying to create a metro by typing in an empty object thus creates one recieve and one osc! Broken, I would say. That plugin have a couple of checks in place, but none that checks for "already standing in an object typing". I've tried looking through other plugins and the tcl's on pd github, but fail to figure out how to perform such a check. It is a bit disheartening, to be honest,
-
Sorry its taken me so long, I've been without internet.
I went ahead and created a plugin for you. It has a bunch of comments and guides through the code. Please post if you don't understand anything, its not as direct as your code.
I'm going to make a gui to edit ALL hotkeys and add new ones, but I hadn't worked every part out yet.
I'll post when I do.