Live Demo โข Report Bug โข Request Feature
- About The Project
- Key Features
- Tech Stack
- Getting Started
- Project Structure
- Game Mechanics
- Deployment
- Contributing
- License
- Contact
- Acknowledgments
Key Trap is a cutting-edge web-based memory and typing challenge game that combines cognitive skills with typing speed. Immerse yourself in a stunning neon-space aesthetic while testing your memory retention and typing accuracy through progressively challenging levels.
The game features a unique two-phase gameplay system:
- Memory Phase: Players memorize answers to questions within a time-limited window
- Typing Phase: Players type the memorized answers as quickly and accurately as possible
Built with modern web technologies and designed with a premium user experience in mind, Key Trap offers smooth animations, glassmorphism effects, and a tri-state neon color system (Emerald, Amber, Crimson) that creates an immersive deep-space nebula atmosphere.
- Dual-Phase Challenge: Memory retention followed by speed typing
- Multiple Difficulty Modes: Easy, Medium, and Hard levels
- Dynamic Scoring System: Points based on speed, accuracy, and difficulty
- Real-time Performance Tracking: WPM, accuracy, and streak statistics
- Progressive Difficulty: Questions become more challenging as you advance
- Premium Neon-Space Theme: Deep space nebula background with animated stars
- Glassmorphism UI: Modern frosted-glass effect components
- Smooth Animations: Powered by Framer Motion for fluid transitions
- Responsive Design: Optimized for desktop, tablet, and mobile devices
- Accessibility: WCAG-compliant color contrasts and keyboard navigation
- Firebase Authentication: Secure user management
- Multiple Sign-in Methods: Email/Password and Google OAuth
- Protected Routes: Authenticated access to game features
- Secure Environment Variables: API keys protected via
.envfiles
- Personal Statistics Dashboard: Track your progress over time
- Achievement System: Unlock badges and milestones
- Leaderboard: Compete with players globally
- Profile Customization: Personalize your gaming experience
- React 18.3.1 - Modern UI library with hooks and context
- React Router DOM 6.30.1 - Client-side routing
- Vite 5.4.19 - Lightning-fast build tool and dev server
- Tailwind CSS 3.4.17 - Utility-first CSS framework
- Framer Motion 12.34.0 - Production-ready animation library
- Firebase 12.9.0 - Backend-as-a-Service
- Authentication (Email/Password, Google OAuth)
- Firestore Database (NoSQL)
- Hosting & Deployment
- Radix UI - Accessible component primitives
- Lucide React - Beautiful & consistent icons
- Sonner - Toast notifications
- TanStack Query - Powerful data synchronization
- ESLint - Code linting and quality
- PostCSS - CSS transformations
- Autoprefixer - Vendor prefix automation
Follow these instructions to set up the project locally for development and testing purposes.
Before you begin, ensure you have the following installed on your system:
-
Node.js (v18.0.0 or higher)
node --version # Should output v18.0.0 or higher -
npm (v9.0.0 or higher) or yarn (v1.22.0 or higher)
npm --version # Should output v9.0.0 or higher -
Git (v2.30.0 or higher)
git --version # Should output v2.30.0 or higher -
Firebase Account - Create one here if you don't have one
# Clone via HTTPS
git clone https://github.com/mdjameee400/key-trap.git
# Or clone via SSH
git clone git@github.com:mdjameee400/key-trap.git
# Navigate to the project directory
cd key-trap# Using npm
npm install
# Or using yarn
yarn installThis will install all required dependencies listed in package.json, including:
- React and React DOM
- Firebase SDK
- Tailwind CSS and plugins
- Framer Motion
- And all other project dependencies
# Check if node_modules directory was created
ls node_modules
# Verify key packages are installed
npm list react firebase vite- Go to Firebase Console
- Click "Add Project" and follow the setup wizard
- Enable Authentication (Email/Password and Google providers)
- Create a Firestore Database (start in production mode)
- Register your web app to get configuration credentials
Create a .env file in the project root directory:
# Copy the example environment file
cp .env.example .envEdit the .env file and add your Firebase configuration:
# Firebase Configuration
VITE_FIREBASE_API_KEY=your_api_key_here
VITE_FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
VITE_FIREBASE_APP_ID=your_app_id
โ ๏ธ IMPORTANT SECURITY NOTES:
- NEVER commit the
.envfile to version control- The
.envfile is already listed in.gitignore- Use
.env.exampleas a template for other developers- Keep your Firebase API keys secure and rotate them if exposed
# Check if .env file exists and is properly formatted
cat .env
# Ensure .env is in .gitignore
cat .gitignore | grep .envStart the development server with hot module replacement (HMR):
npm run devThe application will be available at:
- Local:
http://localhost:5173 - Network:
http://<your-ip>:5173(for testing on other devices)
Build the application for production:
npm run buildThis creates an optimized production build in the dist/ directory.
Preview the production build locally:
npm run previewRun ESLint to check code quality:
npm run lintkey-trap/
โโโ public/ # Static assets
โ โโโ icon.png # Main app logo
โ โโโ numpad.png # Favicon (high visibility)
โ โโโ ...
โโโ src/ # Source files
โ โโโ components/ # React components
โ โ โโโ game/ # Game-specific components
โ โ โโโ HeroScreen.jsx # Landing/menu screen
โ โ โโโ MemoryPhase.jsx # Memory challenge phase
โ โ โโโ TypingPhase.jsx # Typing challenge phase
โ โ โโโ TypingTest.jsx # Main game controller
โ โ โโโ ResultScreen.jsx # Score display
โ โ โโโ ModeSelect.jsx # Difficulty selection
โ โ โโโ StarField.jsx # Animated background
โ โโโ context/ # React Context providers
โ โ โโโ AuthContext.jsx # Authentication state
โ โ โโโ GameContext.jsx # Game state management
โ โโโ lib/ # Utility libraries
โ โ โโโ firebase.js # Firebase configuration
โ โ โโโ gameData.js # Question database
โ โ โโโ utils.js # Helper functions
โ โโโ pages/ # Page components
โ โ โโโ Index.jsx # Home page
โ โ โโโ Auth.jsx # Authentication page
โ โ โโโ NotFound.jsx # 404 page
โ โโโ App.jsx # Root component
โ โโโ main.jsx # Application entry point
โ โโโ index.css # Global styles
โโโ .env # Environment variables (not in repo)
โโโ .env.example # Environment template
โโโ .gitignore # Git ignore rules
โโโ firebase.json # Firebase hosting config
โโโ .firebaserc # Firebase project config
โโโ index.html # HTML entry point
โโโ package.json # Project dependencies
โโโ tailwind.config.js # Tailwind configuration
โโโ vite.config.js # Vite configuration
โโโ README.md # This file
- Question Display: Players are shown a set of questions with their answers
- Memorization Time: A countdown timer gives players time to memorize
- Visual Cues: Questions are color-coded by difficulty
- Preparation: Players mentally prepare for the typing phase
- Question Recall: Questions appear one at a time (without answers)
- Speed Typing: Players type the memorized answers
- Real-time Validation: Instant feedback on accuracy
- Performance Metrics: WPM, accuracy, and time tracking
Base Score = Correct Answers ร Difficulty Multiplier
Time Bonus = Remaining Time ร 10
Accuracy Bonus = (Accuracy % / 100) ร 50
Streak Bonus = Consecutive Correct ร 5
Total Score = Base Score + Time Bonus + Accuracy Bonus + Streak Bonus| Level | Questions | Memory Time | Typing Time | Multiplier |
|---|---|---|---|---|
| Easy | 5 | 30s | 60s | 1x |
| Medium | 8 | 45s | 90s | 1.5x |
| Hard | 12 | 60s | 120s | 2x |
The project is configured for Firebase Hosting deployment.
# Install Firebase CLI globally
npm install -g firebase-tools
# Login to Firebase
firebase login
# Initialize Firebase (if not already done)
firebase init# Build the production bundle
npm run build
# Deploy to Firebase Hosting
firebase deploy
# Or deploy only hosting
firebase deploy --only hostingYour app will be live at: https://your-project-id.web.app
- Go to Firebase Console โ Hosting
- Click "Add custom domain"
- Follow the DNS configuration instructions
- Wait for SSL certificate provisioning (24-48 hours)
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
-
Fork the Project
# Click the 'Fork' button on GitHub -
Clone Your Fork
git clone https://github.com/your-username/key-trap.git cd key-trap -
Create a Feature Branch
git checkout -b feature/AmazingFeature
-
Make Your Changes
- Write clean, readable code
- Follow the existing code style
- Add comments for complex logic
- Update documentation if needed
-
Commit Your Changes
git add . git commit -m "Add: Amazing new feature"
Commit Message Convention:
Add:for new featuresFix:for bug fixesUpdate:for updates to existing featuresRefactor:for code refactoringDocs:for documentation changesStyle:for formatting changesTest:for adding tests
-
Push to Your Fork
git push origin feature/AmazingFeature
-
Open a Pull Request
- Go to the original repository on GitHub
- Click "New Pull Request"
- Select your feature branch
- Provide a clear description of your changes
- Reference any related issues
- Code Quality: Ensure your code passes ESLint checks (
npm run lint) - Testing: Test your changes thoroughly before submitting
- Documentation: Update README.md if you add new features
- Responsive Design: Ensure UI changes work on all screen sizes
- Performance: Optimize for fast load times and smooth animations
- Accessibility: Follow WCAG 2.1 guidelines for accessibility
- Security: Never commit sensitive data or API keys
If you find a bug, please create an issue with:
- Clear title and description
- Steps to reproduce
- Expected vs actual behavior
- Screenshots (if applicable)
- Browser and OS information
We welcome feature suggestions! Please create an issue with:
- Clear description of the feature
- Use case and benefits
- Possible implementation approach (optional)
This project is licensed under the MIT License - see the LICENSE file for details.
MD JAMEE - @mdjameee400 - mdjameee400@gmail.com
Project Link: https://github.com/mdjameee400/key-trap
Live Demo: https://key-trap.web.app
- React Documentation - Comprehensive React guides
- Firebase Documentation - Backend services
- Tailwind CSS - Utility-first CSS framework
- Framer Motion - Animation library
- Lucide Icons - Beautiful icon set
- Radix UI - Accessible components
- Vite - Next-generation frontend tooling
Made with โค๏ธ by MD JAMEE