keys: graphical representation of linux control keys
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 4 Mar 2018 20:49:14 +0000 (21:49 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 5 Mar 2018 22:51:17 +0000 (23:51 +0100)
Represent some control combinations by recognisable symbols for function
keys equivalent in most terminal environments as they are commonly used.
May help people discover easier access.

Enter, tab, and escape should match for all current applications (except
vimperator for an insignificant alias).  Delete and backspace represent
VT100/xterm and ASCII characters, but are different in VT220-based emulators
<http://www.macfreek.nl/memory/Backspace_and_Delete_key_reversed>.
In such cases ^h is distinct from backspace, but likely still works the same
for current occurrences where this is the intended behaviour.

In cases this does not work, the original bindings can still be easily
ascertained from surrounding keys, so should not pose much of a problem.

Shiar_Sheet/Keyboard.pm

index 846a2a2eeaade58f4ae7fda3600ebbb544cc80b5..98c5a40a330a774e564464f4ceb005db21227ce0 100644 (file)
@@ -14,12 +14,12 @@ my %keyrows = do 'keys.inc.pl';
 # add first two cases of each row again with each char prepended by + (alt)
 push @$_, map { [map {"+$_"} @$_] } @$_[0,1] for map {@$_} values %keyrows;
 
-my %keytrans = qw(
-       ^@ NUL ^a SOH ^b STX ^c ETX  ^d EOT ^e ENQ ^f ACK ^g BEL
-       ^h BS  ^i tab ^j LF  ^k VT   ^l FF  ^m CR  ^n SO  ^o SI
-       ^p DLE ^q DC1 ^r DC2 ^s DC3  ^t DC4 ^u NAK ^v SYN ^w ETB
-       ^x CAN ^y EM  ^z SUB ^[ ESC  ^\ FS  ^] GS  ^^ RS  ^_ US
-       ^? DEL
+my %keytrans = (
+       '^h' => "\x{232B}", # BS
+       '^i' => "\x{21E5}", # TAB
+       '^m' => "\x{21B5}", # CR
+       '^?' => "\x{2326}", # DEL
+       '^[' => "\x{238B}", # ESC
 );
 
 sub new {
@@ -95,7 +95,7 @@ sub print_letter {
 
        return if $key eq '^0';
        return 'Esc' if $key eq "\e";
-#      return $keytrans{$key} if defined $keytrans{$key};
+       return $keytrans{$key} if defined $keytrans{$key};
        my $html = $self->{def}{$mode}{lead} . escapehtml($key);
           $html =~ s{\^(?=.)}{<small>^</small>};  # element around ctrl-identifier
           $html =~ s{\+(?=.)}{<small>+</small>};  # meta