A modern ML-powered biometric authentication system that identifies users based on their unique typing patterns. Your keystroke dynamicsβhow long you hold keys, the rhythm between keystrokesβcreate a behavioral biometric signature as unique as your fingerprint.
- π Behavioral Biometrics: Authenticate users based on how they type, not what they type
- π€ ML-Powered: Random Forest classifier with confidence scoring
- π Real-time Analytics: Visualize typing patterns with interactive Plotly charts
- π¨ Modern UI: Sleek dark-themed Streamlit interface
- β‘ Fast Training: Quick model training with minimal samples
The system captures and analyzes three key typing characteristics:
flowchart LR
subgraph capture [Keystroke Capture]
A[Key Press] --> B[Key Release]
B --> C[Timing Data]
end
subgraph features [Feature Extraction]
D[Dwell Time]
E[Flight Time]
F[Digraph Latency]
G[Trigraph Latency]
end
subgraph ml [ML Classification]
H[Random Forest]
I[User Prediction]
J[Confidence Score]
end
C --> D & E & F & G
D & E & F & G --> H
H --> I & J
| Feature | Description | Example |
|---|---|---|
| Dwell Time | How long a key is held down | Hold time for 'e' = 85ms |
| Flight Time | Time between releasing one key and pressing the next | Gap between 't' and 'h' = 120ms |
| Digraph Latency | Time to type common two-letter sequences | 'th' takes 210ms total |
| Trigraph Latency | Time to type common three-letter sequences | 'the' takes 350ms total |
- Python 3.10 or higher
- pip package manager
# Clone the repository
git clone https://github.com/yourusername/keystroke-biometrics.git
cd keystroke-biometrics
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtstreamlit run app.pyThe app will open in your browser at http://localhost:8501
- Navigate to the Register page
- Enter a unique username
- Type 3 sample paragraphs to train your profile
- System learns your unique typing patterns
- Navigate to the Authenticate page
- Type the displayed paragraph naturally
- Click "Authenticate" to identify yourself
- View confidence score and probability distribution
- Navigate to the Analytics page
- Select a user to view their typing profile
- Explore dwell times, digraph patterns, and feature importance
keystroke-biometrics/
βββ app.py # Streamlit main application
βββ src/
β βββ __init__.py
β βββ capture.py # Keystroke timing capture
β βββ features.py # Feature extraction engine
β βββ model.py # ML model (Random Forest)
β βββ utils.py # Helper functions
βββ data/
β βββ users.json # User keystroke profiles
βββ models/
β βββ keystroke_model.joblib # Trained model (generated)
βββ requirements.txt
βββ README.md
| Category | Features | Count |
|---|---|---|
| Dwell Times | e, a, r, i, o, t, n, s, h, l, d, g, space | 13 |
| Digraph Latencies | in, th, ti, on, an, he, al, er, es | 9 |
| Trigraph Latencies | the, and, are, ion, ing | 5 |
| Typing Speed | chars/second | 1 |
# Feature scaling for normalization
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
# Random Forest with balanced class weights
classifier = RandomForestClassifier(
n_estimators=100,
max_depth=10,
class_weight='balanced',
random_state=42
)| Metric | Value |
|---|---|
| Cross-validation Accuracy | ~85-95%* |
| Minimum Users | 2 |
| Samples per User | 3 recommended |
| Feature Dimensions | 28 |
*Accuracy depends on number of users and sample quality
python -m pytest tests/- Add feature extraction in
src/features.py - Update
get_feature_names()andto_vector()methods - Retrain models with new feature set
| Registration | Authentication |
|---|---|
![]() |
![]() |
| Sample Collection | Analytics Dashboard |
|---|---|
![]() |
![]() |
- Keystroke Dynamics - Wikipedia
- Biometric Authentication via Keystroke Dynamics
- scikit-learn Random Forest
| Document | Description |
|---|---|
| CONTRIBUTING.md | How to contribute |
| ROADMAP.md | Future enhancement plans |
| LICENSE | MIT License |
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
Charan
- GitHub: @charanpool
Made with β€οΈ and β¨οΈ




