Keyboard macros: Difference between revisions

Content added Content deleted
(add language: Retro)
(add Ruby)
Line 277: Line 277:


<lang Retro>devector getc</lang>
<lang Retro>devector getc</lang>

=={{header|Ruby}}==
{{libheader|Shoes}}
Here's a sample from the Shoes manual showing how to capture key sequences. This is application specific.

<lang ruby>Shoes.app do
@info = para "NO KEY is PRESSED."
keypress do |k|
@info.replace "#{k.inspect} was PRESSED."
end
end</lang>

A more specific example, using the emacs bindings

<lang ruby>Shoes.app do
keypress do |key|
case key
when \x18 # control-x
@ctrl_x = true
when \x13 # control-s
if @ctrl_x
save_text
@ctrl_x = false
end
when \x11 # control-q
exit if @ctrl_x
end
end
end</lang>


=={{header|Tcl}}==
=={{header|Tcl}}==