A modern, responsive calculator web application built with HTML, CSS, and JavaScript. This calculator provides a clean interface for performing basic arithmetic operations with keyboard and mouse support.
- Basic Arithmetic Operations: Addition (+), Subtraction (-), Multiplication (×), Division (÷)
- Responsive Design: Works seamlessly on desktop and mobile devices
- Keyboard Support: Full keyboard navigation and input support
- Error Handling: Graceful handling of invalid operations and division by zero
- Modern UI: Clean, modern design with smooth animations and hover effects
- Clear Functions: Both Clear (C) and Clear Entry (CE) functionality
- Decimal Support: Proper handling of decimal numbers with validation
├── index.html # Main HTML structure
├── style.css # CSS styling and responsive design
├── script.js # JavaScript functionality with comments
└── README.md # Documentation (this file)
- Clone this repository
- Open
index.htmlin any modern web browser - Start calculating!
- Number Buttons (0-9): Input numbers
- Operator Buttons (+, -, ×, ÷): Perform arithmetic operations
- Equals (=): Calculate and display result
- Clear (C): Clear all input and reset calculator
- Clear Entry (CE): Clear current entry only
- Backspace (⌫): Delete last entered character
- Decimal (.): Add decimal point to numbers
- Number Keys (0-9): Input numbers
- Operator Keys (+, -, *, /): Perform arithmetic operations
- Enter or =: Calculate result
- Escape or C: Clear all
- Backspace: Delete last character
- Decimal (.): Add decimal point
Basic: 5 + 3 = 8
Decimal: 10.5 × 2 = 21
Complex: 15 - 3 × 2 = 9
Division: 100 ÷ 4 = 25
- Safe Expression Evaluation: Uses Function constructor instead of eval() for security
- Error Handling: Comprehensive error catching and user-friendly error messages
- Input Validation: Prevents invalid inputs like multiple decimal points
- Keyboard Integration: Full keyboard event handling for accessibility
- State Management: Proper handling of calculator state between operations
- Grid Layout: Modern CSS Grid for button arrangement
- Responsive Design: Media queries for mobile optimization
- Smooth Animations: Hover and active state transitions
- Modern Aesthetics: Gradient backgrounds and shadow effects
- Accessibility: Focus indicators and proper contrast ratios
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Mobile browsers (iOS Safari, Chrome Mobile)
This is a static web application that requires no build process or dependencies. Simply edit the files and refresh the browser to see changes.
- HTML: Semantic structure with accessibility considerations
- CSS: Modular styling with BEM-like class naming
- JavaScript: Well-commented functions with clear separation of concerns
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly across different browsers
- Submit a pull request
This project is open source and available under the MIT License.