This mimics the javascript virtual keyboards, which are commonly being used by online banks, to avoid keystroke loggers, when entering passwords. It's just the basic model. I still need to run tests on it to see if the letters and passwords can be kept more hidden. But if you ever wanted to play with something like this, but didn't want to go thru all the hassle of building the keyboard...... here is one for you.

The big font I use, makes the script take significantly longer to start up, but is worth it for ease of letter reading.

#!/usr/bin/perl use warnings; use strict; use Tk; # an 8 x 13 grid my @keys = ( '~','`','!','@','#','$','%','^','&','*','(',')','_', '1','2','3','4','5','6','7','8','9','0','-','+','=', 'Q','W','E','R','T','Y','U','I','O','P','{','}','"', 'q','w','e','r','t','y','u','i','o','p','[',']','\'', 'A','S','D','F','G','H','J','K','L',':','|','\\','/', 'a','s','d','f','g','h','j','k','l',';','<','>','?', 'Z','X','C','V','B','N','M','BackSpace','dummy','dummy','dummy','dummy +','dummy', 'z','x','c','v','b','n','m','.','Clear','dummy','dummy','dummy','dummy +'); #print "@keys\n"; my $mw=tkinit; $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=>int(-18*18/14)); my $tframe = $mw->Frame()->pack(-expand=>1,-fill=>'both'); my $passwd = ''; my $label = $tframe->Label(-text => "Password: ", -font => 'big', )->pack(-side=>'left'); my $entry = $tframe->Entry( -show => '*', -textvariable => \$passwd, -bg => 'black', -fg => 'white', -font => 'big', )->pack(-side=>'left',-expand=>1,-fill=>'x', -padx=> 5); my $submit = $tframe->Button( -text=>'Submit', -font => 'big', -bg => 'yellow', -activebackground => 'hotpink', -command => \&submit, )->pack(-side=>'right',-expand=>1,-fill=>'x', -padx=> 5); for my $row (1..8){ my $frame = $mw->Frame()->pack(-expand=>1,-fill=>'both'); for my $col (1..13){ my $l = shift @keys; if($l eq 'dummy'){next}else{ $frame->Button(-text=> $l, -bg => 'beige', -activebackground => 'lightyellow', -font => 'big', -command => [\&process_key, $l], )->pack(-side=>'left',-anchor=>'w', -expand=>1,-fill= +>'both'); } } } MainLoop; ##################### sub process_key{ my $key = shift; print "$key\n"; if ($key eq 'Clear'){$passwd = '';} elsif ($key eq 'BackSpace'){ chop $passwd;} else{ $passwd .= $key;} } ##################### sub submit { print $entry->get(),"\n"; $entry->delete(0,'end'); }

In reply to Tk Virtual Keyboard by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.