You're approaching it from the wrong end. Script to cast the spell should be on the button. If you want a specific keyboard key to trigger the spell as well, just add a UIButtonKeyBinding to that button. You don't need to write any code to trigger anything this way. Just your OnClick() function.