13
1
My Problem
At my current place of employment, I single-handedly (ok dual-handedly because I'm missing no limbs) maintain approximately 700 laptops. Due to the nature and frequency of their use, I often find they are returned with a bit of damage. For this problem, my primary concern is when a laptop is returned with a broken or defunct keyboard. When the hardware repairman fixes these broken keyboards, it becomes necessary to test them. The test involves using each...and...every...single...key. What a drag right? The problem is, sometimes I lose track of if I typed a key or not.
A solution?
Write a program/script that:
- Takes user input
- Upon submission (in whatever way you deem fit), determines whether each key was pressed.
- Outputs yes or no or any way to indicate that either I was successful in pressing all the keys or not. (Indicate in your answer the two possible outputs if it's not something obvious).
Assumptions:
- Uppercase, lowercase, both? Whichever way you deem fit. As long as it's [A-Z], [a-z] or [A-Za-z]. Same goes with numbers and other symbols. (So if = was typed in, + doesn't matter). Your choice if you want to include shifted characters or not.
- You needn't worry about tabs or spaces
- No needs for function keys, CTRL, ALT, Esc or any other keys that don't output something on the screen
- This assumes an EN-US keyboard and the laptops do not include a numpad.
- OS agnostic, whatever language you prefer
- It doesn't matter if the key has been pressed multiple times (for when the tester just gets lazy and starts button smashing like it's Mortal Kombat)
Here's a potential input set that would return true (or yes, or "You did it!")
`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
Winner is determined by the least number of characters.
Do we need to check that each keystroke appears at least once or exactly once? – xnor – 2014-06-07T14:04:11.480
@xnor, If it appears multiple times, it's ok. I updated the question. – SomeShinyObject – 2014-06-07T14:10:27.593
Are we allowed to use external libraries? – nyuszika7h – 2014-06-07T15:10:00.337
@nyuszika7h, yes but it counts toward the total # of chars. – SomeShinyObject – 2014-06-07T15:15:33.780
1Okay then, that isn't worth it. – nyuszika7h – 2014-06-07T15:34:56.793
1
@ChristopherW If this is an ongoing issue for you, you should have a look at this website http://www.keyboardtester.com/.
– gxtaillon – 2014-06-07T15:39:41.8502@MomemtumMori, that hand doing the Pennsylvania Dutch keyboarding technique over in the side bar? Totally mine. – SomeShinyObject – 2014-06-07T15:44:07.313
Can we assume that the input contains only valid characters? – Dennis – 2014-06-07T18:35:30.957
@Dennis, yes you can. – SomeShinyObject – 2014-06-08T21:58:03.863
A quick note: it IS possible that a keyboard can type a lowercase of a certain letter, but doesn't work if you type that same letter with shift. I recently had to replace my keyboard after it failed to recognise uppercase S when I used the shift key. It recognized any lowercase letter, including s, and all uppercase letters excluding S, and it worked using caps-lock. I tested this on both a Mac and a PC, and I even wrote my own keylogger to verify this (which also incidentally unveiled another bug in my keyboard with my F12 key). So yes, you should really test both upper and lowercase. – Nzall – 2014-06-18T10:07:30.447