danlucraft /blog

Cross platform keybindings

November 2009 • Daniel Lucraft

What should the syntax for declaring them look like? At the moment I’m using a hash of platforms, but it feels a bit verbose…. any ideas?

class NewCommand < Command
  key :osx     => "Cmd+N",
      :linux   => "Ctrl+N",
      :windows => "Ctrl+N"
      
  def execute
    tab = win.new_tab(Redcar::EditTab)
    tab.focus
  end
end
blog comments powered by Disqus