A lightweight JavaScript package for typing Nepali words with intelligent suggestions. This package takes input from an editable text field and provides contextual suggestions for Nepali characters and words based on the input. The package supports both simple and complex character combinations, making it a powerful tool for Nepali typing.
- Dynamic suggestions based on the typed input.
- Smart word suggestions with modifiers and character combinations.
- Groups suggestions by their starting character for easier navigation.
- Supports context-sensitive word prediction using the left and right parts of the typed word.
- Works for both standard input fields and content-editable elements.
To use this package, you can either:
- Download the script and include it in your project.
- Use a package manager like npm or yarn.
- Input Field: The field where the user types the Nepali text.
- Suggestions Field: A list container where the Nepali character suggestions will appear.
To initialize the Nepali Typer, call the nepaliTyper()
function, passing the IDs of the input field and suggestion list.
- Input Detection: When the user types in the input field, the package listens for the input and analyzes the text.
- Contextual Suggestions: Based on the typed word, the package calculates possible Nepali characters or words, considering both the base characters and their modifiers.
- Suggestion Grouping: Suggestions are grouped by their first character for easier navigation. If there are more than 10 suggestions, they will be grouped for easier access.
- Selection: When the user clicks on a suggestion, the word is inserted into the text at the cursor's position.
-
nepaliTyper(inputField, suggestionField)
: Initializes the Nepali Typer functionality. -
getOptions(input)
: Returns possible Nepali characters or words based on the input. -
translate(word)
: Translates the word based on available options. -
groupByFirstCharacter(options)
: Groups the suggestions by their first character for better user experience.
-
input
Event on the Input Field: Triggered when the user types in the input field. -
click
Event on Suggestion List: Triggered when a suggestion is clicked to insert it into the input field.
Suppose you're building a Nepali text editor or chat interface. You can use this package to provide contextual suggestions for Nepali characters as the user types, making it easier for them to write in Nepali efficiently.
<input type="text" id="inputField" placeholder="Type Nepali..."/>
<ul id="suggestionField"></ul>
<script type="module" src="script.js"></script>
import { speechToText } from 'https://unpkg.com/nepali-typing@latest/index.js';
nepaliTyper('inputField', 'suggestionField');
- User types "ka" in the input field.
- Suggestions for possible words or characters like "क", "क्", "ख", etc., will appear in the suggestion list.
- User selects one of the suggestions, and the input is updated with the selected word.
MIT License