Skip to content

feat: Add Enter key navigation for form inputs (Feature #13)#63

Merged
MeenakshiAM merged 2 commits into
MeenakshiAM:mainfrom
adithyen:Feature-Req-Allow-Enter-Button-to-mark-Add-Submission-or-to-move-to-the-next-input-field-13
Mar 1, 2026
Merged

feat: Add Enter key navigation for form inputs (Feature #13)#63
MeenakshiAM merged 2 commits into
MeenakshiAM:mainfrom
adithyen:Feature-Req-Allow-Enter-Button-to-mark-Add-Submission-or-to-move-to-the-next-input-field-13

Conversation

@adithyen
Copy link
Copy Markdown
Contributor

@adithyen adithyen commented Mar 1, 2026

Pull Request: Feature #13 – Enter Key Navigation & Submission

Linked Issue

Closes #13

Description

Adds keyboard-first form flow to the Expense Tracker. Users can now fill out and submit the Add Expense form entirely with the keyboard — no mouse clicks required.

Changes Made

script.js

  • Added setupEnterKeyNavigation() function that attaches keydown listeners to all form inputs
  • Tab-like Enter navigation: Name → Amount → Date → Category → submit
  • Category (select): Enter triggers addExpense()
  • Monthly Budget: Enter triggers setBudget()
  • Search field: Enter triggers applyFilters()
  • All handlers use e.preventDefault() to suppress default browser behaviour

index.html

  • Added jsPDF CDN libraries (from previous session — included in this commit)
  • Updated dark mode button to emoji style 🌙/☀️
  • Added 📄 Export to PDF button
  • Added confirm modal

style.css

  • Added styles for .dark-mode-btn, .export-btn, .modal, .modal-content (from previous session)

How to Test

  1. Open index.html (with backend running via node backend/server.js)
  2. Click Expense Name and type a name
  3. Press Enter → focus moves to Amount
  4. Type an amount, press Enter → focus moves to Date
  5. Enter a date, press Enter → focus moves to Category
  6. Press Enter → expense is submitted (same as clicking Add)
  7. Click Monthly Budget, type a value, press Enter → budget is set
  8. Click Search, type something, press Enter → filters apply

##Screenshots
image

Checklist

  • Code follows existing style conventions
  • No double-submit risk (e.preventDefault() on all handlers)
  • All element IDs verified to exist in [index.html]
  • Works alongside existing onclick button handlers

- Name field: Enter moves focus to Amount
- Amount field: Enter moves focus to Date
- Date field: Enter moves focus to Category
- Category dropdown: Enter triggers addExpense() submission
- Monthly Budget field: Enter triggers setBudget()
- Search field: Enter triggers applyFilters()

Closes MeenakshiAM#13
…ubmission-or-to-move-to-the-next-input-field-13
@MeenakshiAM MeenakshiAM merged commit d4463e8 into MeenakshiAM:main Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Req : Allow Enter Button to mark "Add Submission" or to move to the next input field

2 participants