Parameter In A Keybinding Invoke Function?

Just looking at taktiks F+R tool I noticed this was the keybinding declaration (different to most others I`ve used/ seen):

[Lua]renoise.tool():add_keybinding {
name = “Pattern Editor:Tools:Find and Replace”,
invoke = function(repeated)
print(repeated)
if (not repeated) then
show_dialog()
end
end
}
[/Lua]

If I insert a print(repeated) before the if statement, false will be printed when opening the tool. What is the boolean being passed here and why is it necessary?

thanks

The repeated flag simply indicates whether a key has been pressed a single time, or whether the key is held down and therefore repeating. In this particular example it appears that it’s being used to avoid repeatedly calling the show_dialog() function. It’s not strictly necessary I guess, but it’s good practise if the function being called is particularly intensive.

Here’s a simple keybinding which dumps the repeated flag to the status bar, which makes it easier to see what’s going on when you press the key vs holding it down:

  
renoise.tool():add_keybinding {  
 name = "Global:Tools:Key Repeat Test",  
 invoke = function(repeated)  
 renoise.app():show_status('Repeated = ' .. tostring(repeated))  
 end  
}  
  

Thanks dblue, that makes sense.

that helped a lot dblue. thank you.
for anyone needing more help i’ve got it working nicely like this…

local function called_function(repeated)
if repeated == false then
--// your code here because it's not a key repeat
end
end

renoise.tool():add_keybinding {
name = "Global:Tools:A Tool Shortcut",
invoke = called_function
}