We are working hard to bring coding challenges with editor on mobile 💚
Keyboard Navigation
Objective: Implement a simple keyboard navigation system that allows users to navigate between pages, create new pages, and delete pages using keyboard input.
Instructions:
Create a system starting with 10 pages, each representing a simple page (can be a numbered div or section).
Use the left and right arrow keys to navigate between pages.
Pressing Enter should create a new page.
Pressing Backspace should delete the current page.
Requirements:
The system should have 10 pages by default.
Allow users to navigate between pages using the left and right arrow keys.
Pressing Enter should add a new page, and pressing Backspace should delete the current page.
Ensure the user cannot navigate beyond the first or last page.
Example Usage:
Left arrow: Moves to the previous page.
Right arrow: Moves to the next page.
Enter: Creates a new page at the current position.
Backspace: Deletes the current page.
Hints:
Use keyboard event listeners to detect key presses.
Store the pages in an array and update the navigation state accordingly.
Ensure that creating or deleting pages updates the total number of pages and maintains navigation logic.
Bonus:
Allow the user to skip to the first or last page using the Home and End keys.