Closed lobin-z0x50 closed 5 years ago
Looks good, but how about we rewrite it to a case statement, it makes it a bit prettier I think.
def get_key_code which
case which
when String
if which.length != 1
raise ArgumentError, 'can only get key_code of single character strings'
end
which[0].ord
when Symbol
KEY_MAP[which]
when Integer
which
else
raise ArgumentError, "unsupported key value: #{which.inspect}"
end
end
I want to specify the key code directly from my program and perform the key operation.