Is Trigger Keys Or Notes Via Lua Possible?

is it possible to trigger a keyboard key or note vie lua?

Im trying to create a button that will trigger key.name “return” (previews/play sample)

this is all i could find but its for capturing key input not sending it

-------- Introduction  
  
-- Currently there are two ways to to create custom views:  
--  
-- Shows a modal dialog with a title, custom content and custom button labels:  
renoise.app():show_custom_prompt(title, content_view, {button_labels} [,key_handler_func])  
 -> [pressed button]  
  
-- _(and)_ Shows a non modal dialog, a floating tool window, with custom  
-- content:  
renoise.app():show_custom_dialog(title, content_view [, key_handler_func])  
 -> [dialog object]  
  
-- key_handler_func is optional. When defined, it should point to a function  
-- with the signature noted below. "key" is a table with the fields:  
-- > key = {   
-- > name, -- name of the key, like 'esc' or 'a' - always valid   
-- > modifiers, -- modifier states. 'shift + control' - always valid   
-- > character, -- character representation of the key or nil   
-- > note, -- virtual keyboard piano key value (starting from 0) or nil   
-- > repeated, -- true when the key is soft repeated (hold down)   
-- > }  
--  
-- "dialog" is a reference to the dialog the keyhandler is running on.  
--  
-- function my_keyhandler_func(dialog, key) end  

im yet to try it but I am guessing for triggering notes.

  
  
midi_device:send(message_table)  
  
  

well this fails

local function key_handler(dialog, key)  
 key.name = "esc"  
 end  
  

maybe its time to give up on this idea?

I don’t think there is a way to do that.

As far as I know, the keyhandler function is solely for the purpose of catching keys on a custom dialog window - the tool GUI. I know that you can, through this keyhandler function, pass keys to renoise by using a ‘return key’ -statement. (Where ‘key’ is the keypress catched by the keyhandler)

As in:

  
local function my_keyhandler(dialog, key)  
  
 return key  
  
end  
  

This would send the keypress to renoise. Again, AFAIK the sent keybindings will be interpreted in ‘Global’ context. Meaning you could possibly trigger global keybinds by editing key.name and key.modifiers in the keyhandler, and then return the edited key.

I don’t know if this works, but maybe something like:

  
local function my_keyhandler(dialog, key)  
  
 key.name = "return"  
 key.modifiers = nil  
  
 return key  
  
end  
  

But the triggering would require a keypress when your tool is activated, and in the foreground… So I don’t see how this would be useful.

You can only pass back existing events to Renoise. You can’t generate new key events this way.
In short: “Trigger Keys Or Notes Via Lua” is not possible at the moment.

1 Like