I'm using Ruby and Tk. I want to know the keysyms of various odd keys on my unusual keyboard. I want to know what they really are, not merely what some reference (such as this) says they should be.
Asked
Active
Viewed 39 times
1 Answers
0
This code worked for me using Ruby 2.2.5 (with Tk 8.5.12) on Windows 7:
# coding: utf-8
require 'tk'
def lambda_keypress
@lambda_keypress ||= Kernel.lambda do |key_code, key_symbol|
puts "lambda_keypress invoked with keycode #{key_code} and keysym #{key_symbol}."
end
end
def root
$root ||= begin
Tk::Encoding.encoding = ''.encoding
TkRoot.new
end
end
root.bind :KeyPress, lambda_keypress, '%k %K'
Tk.mainloop

MarkDBlackwell
- 1,994
- 18
- 27