Type the Alphabet - as fast as you can!

Your task is to make a program that measures how fast you can type the letters of the English alphabet.

• The program shall only accept lowercase letters a to z in alphabetical order.
• Each letter is echoed as typed on the same line (without new line or any other separators between letters).
• If you type an invalid character the program shall output Fail on a new line and exit.
• If you type all 26 letters the program shall, on a new line, output the time in milliseconds it took from the first to the last letter and exit.
• The timer starts when you type the first letter, a.

Example outputs:

b
Fail

abcdefgg
Fail

abcdefghijklmnopqrstuvwxyz
6440

This is , so shortest answer in bytes wins.

• Relevant project I made a while back. (the 15th level is basically this) – ETHproductions Oct 29 '17 at 19:42
• Can we output Fail without a heading newline? (e.g. abdFail\n or abd Fail\n)) – scottinet Oct 30 '17 at 8:44
• @scottinet, no, the result (Fail or milliseconds) must be on a new line, like in the example. Most answers already assume this. – Danko Durbić Oct 31 '17 at 6:29
• -1 as this "new" rule was not in the original specification and invalidates my suggestions on one of the Python answers which was within the original rules. – ElPedro Oct 31 '17 at 9:35
• I was expecting this to be a fastest-code challenge of printing the alphabet. – ATaco Nov 2 '17 at 1:19

HTML (JavaScript (ES6)), 129126 117 bytes

<input id=i onfocus=l=0,n=Date.now onkeypress=event.which-97-l?i.outerHTML='Fail':24<l?i.outerHTML=n()-t:t=l++?t:n()>

Click in the input and start typing! Also, my typing sucks; I take about 5 seconds even with practice. Edit: Saved 2 bytes thanks to @HermanLauenstein by switching language. Saved 3 bytes thanks to @qw3n. Saved 9 bytes thanks to @tsh.

• -2 bytes by using html with a script tag: <input id=i><script>l=0;n=Date.now;i.onkeypress=e=>e.charCode-97-l?i.outerHTML='Fail':l>24?i.outerHTML=n()-t:t=l++?t:n()</script>, -11 bytes if the closing tag isn't needed – Herman L Oct 29 '17 at 11:02
• @HermanLauenstein The closing tag seems to be necessary for a snippet, at least, so I'll leave it in. – Neil Oct 29 '17 at 11:35
• This is too infuriating and fun at the same time. – Zenon Oct 29 '17 at 23:26
• What about put event on input? <input id=i onkeypress=event.which-97-l?i.outerHTML='Fail':24<l?i.outerHTML=n()-t:t=l++?t:n() onfocus=l=0,n=Date.now> – tsh Oct 30 '17 at 2:27
• Doesn't echo the text on a new line – dkudriavtsev Oct 30 '17 at 19:40

6502 machine code (C64 PAL), 189 165 bytes

00 C0 A9 17 8D 18 D0 A9 40 85 FE E6 FE 20 E4 FF F0 FB 20 D2 FF C5 FE 38 D0 38
C9 5A 18 F0 33 C9 41 D0 E8 A9 00 85 FC 85 FD A9 18 85 FB A9 7F 8D 0D DD A9 7F
8D 18 03 A9 C0 8D 19 03 A9 D8 8D 04 DD A9 03 8D 05 DD A9 01 8D 0E DD A9 81 8D
0D DD D0 B9 A9 7F 8D 0D DD A9 47 8D 18 03 A9 FE AD 19 03 CE 0E DD B0 14 A9 0D
20 D2 FF A4 FC A5 FD 20 91 B3 20 DD BD A9 01 A8 D0 04 A9 9D A0 C0 4C 1E AB 48
AD 0D DD 29 01 F0 14 E6 FC D0 02 E6 FD C6 FB D0 0A A9 18 85 FB CE 0E DD EE 0E
DD 68 40 0D C6 41 49 4C 00
• -24 bytes by inlining functions and not caring for other CIA2 interrupts

Online demo (Usage: sys49152)

Explanation:

This would be a tiny program if it wasn't for the problem of an exact measurement of milliseconds on the C64. The system interrupt occurs roughly 60 times per second, which isn't even close. So we have to use a hardware timer here that gets its input ticks from the system clock.

On a PAL machine, the system clock is exactly 985248 Hz. Initializing the timer to 985 therefore gives something close to millisecond ticks, but it's a bit too fast, we'd have to count 986 cycles for every fourth tick, or hold the timer for a single cycle. This isn't possible, but we can hold the timer for 6 cycles with the sequence DEC $DD0E, INC$DD0E: $DD0E is the timer control register with bit 0 switching it on and off, and both instructions take 6 cycles, so the exact writes that stop and start the timer are exactly 6 cycles apart. Therefore we have to execute this sequence every 6*4 = 24th tick. This still isn't absolutely exact, the timer will lag 1 millisecond behind after 8 minutes and 12 seconds, but it's probably good enough -- compensating for that one would take a lot of code. edit: The start value for the timer must be 984, not 985, because these timers fire "on underflow", so a value of 0 will count one more cycle before firing. Code fixed, byte count unchanged. Here's the commented disassembly listing: 00 C0 .WORD$C000        ; load address
.C:c000  A9 17       LDA #$17 ; mode for upper/lower text .C:c002 8D 18 D0 STA$D018          ; set in graphics chip
.C:c005  A9 40       LDA #$40 ; initialize expected character .C:c007 85 FE STA$FE            ; to 'a' - 1
.C:c009   .mainloop:
.C:c009  E6 FE       INC $FE ; increment expected character .C:c00b .getchar: .C:c00b 20 E4 FF JSR$FFE4          ; read character from keyboard
.C:c00e  F0 FB       BEQ .getchar       ; until actual character entered
.C:c010  20 D2 FF    JSR $FFD2 ; output this character .C:c013 C5 FE CMP$FE            ; compare with expected
.C:c015  38          SEC                ; set carry as marker for error
.C:c016  D0 38       BNE .result        ; wrong character -> output result
.C:c018  C9 5A       CMP #$5A ; compare with 'z' .C:c01a 18 CLC ; clear carry (no error) .C:c01b F0 33 BEQ .result ; if 'z' entered, output result .C:c01d C9 41 CMP #$41           ; compare with 'a'
.C:c01f  D0 E8       BNE .mainloop      ; if not equal repeat main loop
.C:c021  A9 00       LDA #$00 ; initialize timer ticks to 0 .C:c023 85 FC STA$FC
.C:c025  85 FD       STA $FD .C:c027 A9 18 LDA #$18           ; counter for adjusting the timer
.C:c029  85 FB       STA $FB .C:c02b A9 7F LDA #$7F           ; disable all CIA2 interrupts
.C:c02d  8D 0D DD    STA $DD0D .C:c030 A9 7F LDA #<.timertick ; set NMI interrupt vector ... .C:c032 8D 18 03 STA$0318
.C:c035  A9 C0       LDA #>.timertick
.C:c037  8D 19 03    STA $0319 ; ... to our own timer tick routine .C:c03a A9 D9 LDA #$D8           ; load timer with ...
.C:c03c  8D 04 DD    STA $DD04 .C:c03f A9 03 LDA #$03
.C:c041  8D 05 DD    STA $DD05 ; ... 985 (-1) ticks (see description) .C:c044 A9 01 LDA #$01           ; enable timer
.C:c046  8D 0E DD    STA $DD0E .C:c049 A9 81 LDA #$81           ; enable timer interrupt
.C:c04b  8D 0D DD    STA $DD0D .C:c04e D0 B9 BNE .mainloop ; repeat main loop .C:c050 .result: .C:c050 A9 7F LDA #$7F           ; disable all CIA2 interrupts
.C:c052  8D 0D DD    STA $DD0D .C:c055 A9 47 LDA #$47           ; set NMI interrupt vector ...
.C:c057  8D 18 03    STA $0318 .C:c05a A9 FE LDA #$FE
.C:c05c  AD 19 03    LDA $0319 ; ... back to system default .C:c05f CE 0E DD DEC$DD0E          ; disable timer
.C:c062  B0 14       BCS .fail          ; if carry set, output fail
.C:c064  A9 0D       LDA #$0D ; load newline .C:c066 20 D2 FF JSR$FFD2          ; and output
.C:c069  A4 FC       LDY $FC ; load timer value in .C:c06b A5 FD LDA$FD            ; A and Y
.C:c06d  20 91 B3    JSR $B391 ; convert to float .C:c070 20 DD BD JSR$BDDD          ; convert float to string
.C:c073  A9 01       LDA #$01 ; load address of .C:c075 A8 TAY ; string buffer .C:c076 D0 04 BNE .out ; and to output .C:c078 .fail: .C:c078 A9 9D LDA #<.failstr ; load address of "Fail" string .C:c07a A0 C0 LDY #>.failstr ; in A and Y .C:c07c .out: .C:c07c 4C 1E AB JMP$AB1E          ; done; OS routine for string output
.C:c07f   .timertick:
.C:c07f  48          PHA                ; save accu
.C:c080  AD 0D DD    LDA $DD0D ; load interrupt control register .C:c083 29 01 AND #$01           ; to know whether it was a timer NMI
.C:c085  F0 14       BEQ .tickdone      ; if not -> done
.C:c087  E6 FC       INC $FC ; increment timer ticks ... .C:c089 D0 02 BNE .adjusttick .C:c08b E6 FD INC$FD            ; high byte only on overflow
.C:c08d   .adjusttick:
.C:c08d  C6 FB       DEC $FB ; decrement counter for adjusting .C:c08f D0 0A BNE .tickdone ; not 0 yet -> nothing to do .C:c091 A9 18 LDA #$18           ; restore counter for adjusting
.C:c093  85 FB       STA $FB .C:c095 CE 0E DD DEC$DD0E          ; halt timer for exactly
.C:c098  EE 0E DD    INC $DD0E ; 6 cycles .C:c09b .tickdone: .C:c09b 68 PLA ; restore accu .C:c09c 40 RTI .C:c09d .failstr: .C:c09d 0D C6 41 .BYTE$0D,"Fa"
.C:c0a0  49 4C 00    .BYTE "il",$00 • Well, now I have a somewhat decent millisecond timer in my toolbox ;) might be useful some day. – Felix Palmen Oct 30 '17 at 16:53 • Pay attention, script kiddies. This is real golf. – J... Oct 31 '17 at 17:23 • @J... I could golf it further by inlining .starttimer -- will do soon :) (and even further by using the system TI like this BASIC answer, but I'm not sure this is valid, because you can do better in machine code) – Felix Palmen Oct 31 '17 at 22:26 • Wow, I missed a factor of 985 when calculating the error in my time measurement first -- it's actually pretty good the way it is (if I made another error in my calculations, please point out!) :) – Felix Palmen Nov 1 '17 at 10:54 • And do you see what this guy have in the GITHUB?: android boot recovery.... he is completely insane! favorited his profile. – Luciano Andress Martini Jan 9 '19 at 11:58 Bash + coreutils, 10399 98 bytes for((;c==p%26;r=date +%s%3N-(s=s?s:r),c=62#$c-9,p++))
{
read -N1 c
}
((c==p))||r=Fail
echo "
$r" Must be run in a terminal. Test run$ bash type.sh
abcdefghijklmnopqrstuvwxyz
3479
$bash type.sh abcz Fail$ bash type.sh 2>&- # typing '@' would print to STDERR
ab@
Fail
3C$=INKEY$:IFC$=""GOTO3 4RETURN TIME is an internal MSX-BASIC variable that increases by one every 20 milliseconds. C# (.NET Core), 184+13=197 173+13=186 bytes ()=>{var s=DateTime.Now;var i=97;while(i<123&&Console.ReadKey().KeyChar==i)if(i++<98)s=DateTime.Now;Console.Write(i>122?$"\n{(DateTime.Now-s).TotalMilliseconds}":"\nFail");}

Try it online!

Unfortunately TIO can't run this, but it's handy for getting byte count.

+13 for using System;

-1 by changing i==123 to i>122. I was tempted to make this i>'z'.

Acknowledgements

-10 bytes thanks to @raznagul

Ungolfed

()=>{
var s=DateTime.Now;
var i=97;

while(i<123&&Console.ReadKey().KeyChar==i)
if(i++<98)
s=DateTime.Now;

Console.Write(i>122?
$"\n{(DateTime.Now-s).TotalMilliseconds}": "\nFail" ); } • You can save some bytes by moving the ReadKey to the loop condition so you can remove the first if and the break. – raznagul Oct 30 '17 at 10:50 Node.js, 240 213 bytes require('readline',{stdin:i,stdout:o,exit:e}=process).emitKeypressEvents(i) w=s=>o.write(s) n=0 i.on('keypress',c=>w(c)&&c.charCodeAt()-97-n?e(w( Fail)):!n++?s=d():n>25&&e(w( +(d()-s)))).setRawMode(d=Date.now) EDIT: Saved 27 bytes thanks to Jordan Ungolfed version: const readline = require('readline') let index = 0 let start readline.emitKeypressEvents(process.stdin) process.stdin.setRawMode(true) process.stdin.on('keypress', character => { process.stdout.write(character ) // Lookup character in ASCII table if (character !== String.fromCharCode(97 + index) { process.stdout.write('\nFail') process.exit() } index++ if (index === 1) { start = Date.now() } if (index === 26) { process.stdout.write('\n' + (Date.now() - start)) process.exit() } }) C (gcc), 303 bytes Works on *nix systems. Standalone code removing the current terminal's canonical mode to allow reading characters without waiting for newlines: /!\ Running this program will make the terminal almost unusable. #import <stdlib.h> #import <termios.h> #define x gettimeofday(&t,0) #define r t.tv_sec*1000+t.tv_usec/1000 c,i=97;main(){long s=0;struct termios n;struct timeval t;cfmakeraw(&n);n.c_lflag|=ECHO;tcsetattr(0,0,&n);for(;i<'d';){c=getchar();if(c!=i++)puts("\nFail"),exit(0);x;s=s?:r;}x;printf("\n%ld",r-s);} Ungolfed and commented: // needed in order to make gcc aware of struct termios // and struct timeval sizes #import <stdlib.h> #import <termios.h> // gets the time in a timeval structure, containing // the number of seconds since the epoch, and the number // of µsecs elapsed in that second // (shorter than clock_gettime) #define x gettimeofday(&t,0) // convert a timeval structure to Epoch-millis #define r t.tv_sec*1000+t.tv_usec/1000 // both integers // c will contain the chars read on stdin // 97 is 'a' in ASCII c,i=97; main(){ long s=0; // will contain the timestamp of the 1st char entered struct timeval t; // will contain the timestamp read from gettimeofday // setting up the terminal struct termios n; cfmakeraw(&n);//create a raw terminal configuration n.c_lflag|=ECHO;//makes the terminal echo each character typed tcsetattr(0,0,&n);//applies the new settings // from 'a' to 'z'... for(;i<'{';){ // read 1 char on stdin c=getchar(); // if int value of the input char != expected one => fail&exit if(c!=i++)puts("\nFail"),exit(0); // macro x: get current timestamp x; // if not already set: set starting timestamp s=s?:r; } // get end of sequence timestamp x; // prints the end-start timestamps difference printf("\n%ld",r-s); } Alternative solution (218 bytes): If configuring the terminal beforehand is allowed, then we can get rid of the portion of code handling that part. Here is the same code without terminal manipulation: #import <stdlib.h> #define x gettimeofday(&t,0) #define r t.tv_sec*1000+t.tv_usec/1000 c,i=97;main(){long s=0;struct timeval t;for(;i<'{';){c=getchar();if(c!=i++)puts("\nFail"),exit(0);x;s=s?:r;}x;printf("\n%ld",r-s);} To make it work:$ gcc golf.c
$stty -icanon$ a.out

runtime example:

Commodore BASIC v2 - 113 bytes

Capital letters must be shifted.
Thanks to Felix Palmen for pointing out some typos, specs
try it

0d=64
1on-(f=26)gO5:gEa$:ifa$=""tH1
2iff=0tHt=ti
3f=f+1:ifa$<>cH(d+f)tH6 4?cH(14)a$;:gO1
5?:?(ti-t)/60*1000:eN
6?"Fail"
• Click edit to see the corrected markdown code. – NieDzejkob Oct 31 '17 at 14:26
• Welcome to the site! Could you add a link to an interpreter (if one exists), so that others can test your code? – caird coinheringaahing Oct 31 '17 at 14:37
• Well, this uses the system IRQ (TI is incremented in it) I deemed unsuitable for its lack of precision, but I guess it's fair game here because there's just no way to do better in BASIC :) Still, pasting this in vice, I get a syntax error in 1 -- any help? – Felix Palmen Oct 31 '17 at 15:51
• Figured it out myself, you have a typo in line one, should be 1on-(f=26)gO4:gEa$:ifa$=""tH1 Nitpicks: 1.) output is on the same line, 2.) output is all-caps -- I think you should fix those, won't take many bytes anyways :) – Felix Palmen Oct 31 '17 at 15:56
• Adressed the issues, any typos left? – mondlos Oct 31 '17 at 17:19

Perl 5, 79 93 +31 (-MTerm::ReadKey -MTime::HiRes=time) bytes

$|=1;map{ReadKey eq$_||exit print"
Fail";$s||=time}a..z;print$/,0|1e3*(time-$s)$|=1 is not sufficient to set terminal in raw mode, stty -icanon should be run before or

ReadMode 3;map{ReadKey eq$_||exit print" Fail";print;$s||=time}a..z;print$/,0|1e3*(time-$s)

to see characters in the terminal after running command : stty echo or stty echo icanon

• Good old ReadKey! You can save a few bytes here and there, 1e3 for 1000, $s||=time and if you set$s first and then call ReadKey, you can swap out the map to a postfix for. I'd like to say die instead of exit print, but I think you're right there... I tinkered with printf"\n%i" but that ended up larger, and I thought about using $- instead of$s, but that was stupid! :) – Dom Hastings Oct 30 '17 at 16:33
• @DomHastings, thank you for your help, I could save 4 bytes, but i added 5 bytes to set unbuffered input $|=1;, also$s||=time can't be swap out the map because timer must start after first key pressed, and die would echo Fail on stderr instead of stdout. – Nahuel Fouilleul Oct 31 '17 at 7:50
• Happy to help, hope you don't mind me offering ideas! Yeah, it's s shame, exit print is so long! Sorry, I don't think I explained my thought for the for properly: $s||=time,ReadKey eq$_||exit print" Fail"for a..z should work I think... Maybe even $|=$s||=... or $|=map... if you prefer that approach! Think you pretty much nailed it though! – Dom Hastings Oct 31 '17 at 8:31 •$|=map.. doesn't set unbuffered input in new terminal (I had the error when removing, ReadMode 3, because I was testing in the same session), and $s||=time before first ReadKey would start timer too early – Nahuel Fouilleul Oct 31 '17 at 9:42 • Ahh, I misunderstood, I get it now, didn't wait long enough after starting to script to check that... :) Shame about$|, but again, it's storing after the loop which is too late! You're one step ahead! – Dom Hastings Oct 31 '17 at 9:46

Aceto, 70 bytes

d'|d 't9
$z=p zp1 != >#v d, 1 + cTpaXpn3 Io$'p"*F
|'!=ilnu
@ad,aF"

I start by setting a catch mark and mirroring horizontally(@|), if the value on the stack is truthy. It isn't initially, and later always will be. We will jump back here later if a wrong key is entered. Next, we push an a on the stack ('a), then we duplicate it and read a single character from the user (d,). If the two characters are not equal (=!), we "crash" ($) and jump back to the catch mark. Otherwise, we push another "a" and print it, then we set the current time ('apT). Then we enter our "main loop": We "increment" the current character and "increment" the character ('apToIc), then we duplicate it, read a new character, compare it, and "crash" if it the characters aren't identical (d,=!$). If we didn't crash, we compare the current character to "z" (d'z=|), if it isn't equal, we print the character, then we push a 1 and jump "conditionally" (in this case: always) to the only o in the code (the begin of our main loop). If it was equal to z, we mirrored horizontally to some empty space on top. We print "z", then push the current time (minus the starting time; t) and then multiply the number 1000 (gotten by raising 10 to the third power; 91+3F) by it (because we get seconds, not milliseconds). Then we print a newline, the time, and exit (pX).

If we ever crash (bad input by the user), we jump all the way to the beginning. Since we will now have some truthy value on the stack, we will mirror horizontally onto the u, which reverses the direction we're moving in. n prints a newline character, then we push "Fail" on the stack, print it, and exit (pX).

APL (Dyalog), SBCS, 114 153 bytes

Using a GUI form to handle keypress events:

t←⍬
a←819⌶⎕A
f←{⍬≡t:f ⍵⊣t⊢←⎕AI⋄⊃a≠⍞←3⊃⍵:⎕EX⎕A⊣⎕←'Fail'⋄'z'=a~←⊃a:⎕←3⊃⎕AI-t}
⎕DQ⎕A⎕WC'Form'('Event' 'KeyPress' 'f')

(Golfed by Adám; I think it would be odd for him to be awarding a bounty for an answer which is now mostly his golf rewrite, so that's here, and my original is below. This version handles the "exit on failure" part of the spec, too.]

t←⍬
a←(819⌶)⎕A
∇w
'W'⎕WC'Form'('Event' 'KeyPress' 'f')
⎕DQ'W'
∇
∇f e
{26=≢a:t⊢←⎕TS}⍬
{e[3]=1↑a:{⍞←1↑a⋄a⊢←1↓a}⍬⋄⎕←'Fail'}⍬
{0=≢a:⎕←60 60 1e3⊥4↓⎕TS-t}⍬
∇
w

Image of it (the first posted version) in use, Dyalog APL 17.1:

Explanation.

It's a function w which loads a GUI form and adds an event handler to it, and starts listening for events, and the call back which handles the alphabet.

Lambda functions are used to get guard pattern matching, instead of longer :If ⋄ cond ⋄ code ⋄ :Else ⋄ code ⋄ :EndIF syntax. Guards are {cond: code} pattern, and the {}⍬ pattern is calling a function on an empty numeric vector just to make it run

t←⍬  ⍝ Variable for the time of starting typing

a←(819⌶)⎕A  ⍝ Variable for lowercase alphabet,
cast from uppercase with I-beam 819

⍝ Function "w" makes window of type 'Form', called 'W', with event handler.
⍝ Callback function "f", and starts event loop.
∇w
'W'⎕WC'Form'('Event' 'KeyPress' 'f')
⎕DQ'W'
∇

⍝ event handler function "f" takes event "e"
∇f e

{26=≢a:t⊢←⎕TS}⍬    ⍝ lambda function (dfn)
⍝ checks if there are 26 letters,
⍝ (i.e. started typing) starts the timer.
⍝ "t" is initialised first, for global scoping.

{e[3]=1↑a:{⍞←1↑a⋄a⊢←1↓a}⍬⋄⎕←'Fail'}⍬ ⍝ guard, if event[3] (key pressed)
⍝ is the next alphabet letter (first of "a")
⍝ print 1 from "a", drop 1 from "a"
⍝ else print "Fail".

{0=≢a:⎕←60 60 1e3⊥4↓⎕TS-t}⍬  ⍝ guard, if all the letters are gone,
⍝ subtract current timestamp from stored,
⍝ drop 4 elements (year, month, day, hour)
⍝ base-convert min, sec, ms to pure ms
⍝ and print.
∇

⍝ run it by calling function "w"
w

Mathematica (notebook expression), 248 bytes

DynamicModule[{x={},s=0,t=0},EventHandler[Framed@Dynamic[If[x=={"a"}&&s<1,s=SessionTime[]];Which[x==a,If[t==0,t=SessionTime[]-s];1000t,x==a~Take~Length@x,""<>x,1>0,"Fail"]],Table[{"KeyDown",c}:>x~AppendTo~CurrentValue@"EventKey",{c,a=Alphabet[]}]]]

How it works

DynamicModule[{x={},s=0,t=0},
EventHandler[
Framed@Dynamic[
If[x=={"a"} && s<1,s=SessionTime[]];
Which[
x==a,If[t==0,t=SessionTime[]-s];1000t,
x==a~Take~Length@x,""<>x,
1>0,"Fail"]],
Table[{"KeyDown",c}:>x~AppendTo~CurrentValue@"EventKey",
{c,a=Alphabet[]}]]]

A DynamicModule with an EventHandler that responds to lowercase letter keypresses. The variables x, s, and t hold the letters pressed so far, the start time, and the end time, respectively. As soon as we notice x being equal to {"a"}, we start the time; we display either the total time spent, or the string built so far, or "Fail" depending on which condition is met.

We could save another byte with t<1 rather than t==0 if we can assume that nobody is fast enough to type the alphabet in less than one second :)

If you're trying this out in a Mathematica notebook, keep in mind that you have to click inside the frame before your keypresses will be registered. (This is the reason that we need the frame to begin with; if Framed is not there, then the entire object selected changes when a key is pressed, so it stops being selected and you'd have to click again.)

C#, 154 152 + 13 = 165 bytes

Saved 2 bytes thanks to Ayb4btu's comments

x=>{
long t=0,c=97;
for(;Console.ReadKey().KeyChar==c++&&c<123;t=t<1?DateTime.Now.Ticks:t);
Console.Write(c>122?"\n"+(DateTime.Now.Ticks-t)/1e4:"\nFail");
}

The code above has whitespace to make it fit in SE without a scrollbar. Whitespace isn't part of the byte count

and 13 bytes for using System;

It's similar to Ayb4btu's version but with the following differences:

• Storing datetime as a long, allows us to make c a long also, and short cut the declaration

• Loop doesn't need a separate break

• It's not actually shorter to use \$"interpreted strings" versus adding a needed "\n" onto the milliseconds to make it a string for the inline if

• Using a for loop sometimes allows us to save chars over a while, though I think this one wouldn't save over the equivalent while

From Ayb4btu:

• s=s==0 can become s=s<1, and c==123 can become c>122

Ungolfed

long t=0,c=97;

for (;                                         //no loop vars declared
Console.ReadKey().KeyChar == c++ && c < 123; //loop test
t = t < 1 ? DateTime.Now.Ticks : t          //post-loop assigns
) ;                                            //empty loop body!

//now just need to turn ticks into millis, 10,000 ticks per millis
Console.Write(c>122?"\n"+(DateTime.Now.Ticks-t)/1e4:"\nFail");
• Nice solution with how you used DateTime. You can save a couple more bytes by changing s=s==0 to s=s<1 (counting on the fact that s will not be negative), and changing i==123 to i>122. – Ayb4btu Oct 31 '17 at 0:20
• Also, has this been tested? As I found that i<123 had to go before the ReadKey(), otherwise it waits for another character after z before displaying the time. – Ayb4btu Oct 31 '17 at 0:41
• Odd, because at the end of the alphabet, z should mean readkey.keychar returns 122 when the user types z, c is also 122, hence 'z' == 122 succeeds, c is then incremented, then c (now 123) is tested against c<123 and fails, stopping the loop .. ? – Caius Jard Oct 31 '17 at 10:10
• You're right, I missed the c++ increment when I was looking at it. However, I just tried it and when I type in abcdefghijklmnopqrstuvwxys it gives me a time instead of failing. I believe it is because c still increments even though the KeyChar check fails, therefore passing the c>122 check. – Ayb4btu Oct 31 '17 at 19:25
• Good point - maybe moving the ++ to the c<123 check will keep the bytecount the same and prevent the c from incrementing if the last char is wrong - no time to debug right now, but I'll take a look at it! cheers :) – Caius Jard Nov 1 '17 at 18:31

Processing.org 133 142

first code didn't exit

char k=97;int m;void draw(){if(key==k){m=m<1?millis():m;print(key=k++,k>122?"\n"+(millis()-m):"");}if(m>0&&key!=k-1){print("\nFail");exit();}}

GCC, windows, 98 bytes

t;main(i){for(;i++<27;t=t?:clock())if(95+i-getche())return puts("\nFail");printf("\n%d",clock()-t);}

Requires no instantly input for the first key