Project 2: Type Keys
Background Info
Once upon a time there were keyboards attached directly to printers, and they were called typewriters. They didn’t require electricity to work, and they were used by people everywhere for about 130 years. They looked like this.
-
Oringinally, only one keyboard layout was used; back in 1868 Christopher Sholes patented the typewriter with the QWERTY keyboard, so-called because of the left-to-right order of the top row of letter keys.
-
In 1932, Professor August Dvorak at Washington State University set out to develop a better keyboard, with more common keys in the home row, with vowels to one side and consonants to the other, to increase the likelihood of hands taking turns, which seemed like it would speed up typing. He named this keyboard layout after himself.
Project Description
In this program, we will do a very basic and determinable exploration of the two layouts, comparing and contrasting them. We will do via reading a text file (to act as the document “being typed”), and utilizing provided measurements of keys’ distances from the home row, and this program assumes user is “touch-typing” using all 10 fingers (8 on home row). We will be turning the file into words one would type on a typing test, so rules on how to strip the words into usable form are described below.
| QWERTY Keyboard | DVORAK Keyboard |
|---|---|
![]() |
![]() |
Actual Problem to Solve
Rules that we are provided with to format the words are as follows:
- Upper and lower-case letters are considered the same keyboard position, and so do not need to be treated separately => for time-sensitive purposes, ignore shifting (A = Shift+a)
- For the sake of word counts, white space (space, tab, carriage-return) separates words
- Punctuation at the beginning and at the end of a word should not change the statistics for that word => should *not* be considered as characters in the word:
- In the word
ain't, the'is considered as part of typing the word - In the word
over., the.is not considered as part of typing the word
- In the word
- Total distance travelled by fingers is in miles, to 3 decimal places; it also assumes the following things:
- In the home row typing a middle key is moving
.75 of an inchgorhon a QWERTY keyboard
- Each time a finger leaves the home position for the row immediately above or below, that is moving
.75 of an inch, with the following exceptions:TandYare each1 inch;Bis1.25 inches
- Each time a finger leaves the home row for the top (numbers) row, that is moving
1.5 inches, with the exception that6and^are1.75 inches
- In the home row typing a middle key is moving
Output (Not Accurate, Just for Reference)
Author: Anthony Makis
Program: #2, Type Keys
First two lines of the input file are:
TWENTY THOUSAND LEAGUES UNDER THE SEA
by JULES VERNE
Total words: 4326
Total non-blank characters: 32098
Qwerty Dvorak
% All Characters on home row: 3 40
% All Words on home row: 25 43
% Words typed on one hand: 17 13
Distance travelled(miles): 1.583 0.796
Project Structure
This is to be developed in one stage, procedurally. There are 2 files being provided to us:
- readFromFileAndParseWords.c => basic example of using fgets() to read “lines” of a file
- 20000LeaguesUnderTheSeaJulesVerne.txt => the text file “being typed”
Restrictions for this Project
We were only *loosely* prompted to use fgets() for this task, and we were also allowed to try to use strtok(); other than this there weren’t any extra requirements :)
We were also told that: “For reference sake, typing at 60 wpm for 7 hours a day it would take you over 4 days to type the book”. This will be a useful benchmark in retrospect of running the solution.
Any further, atomic requirements are described in the different Stages!
My Solution in Action

I have a
Makefilefor quicker compilation, and then we run the executable (v1).Makefileis written to support general compilation of most.cfiles, so I will reuse it throughout projects, making updates to it ocassionally.
Results Screenshot


