|
1 | 1 | # AngularTouchKeyboard
|
2 | 2 |
|
| 3 | +An Angular touch keyboard component that provides a customizable on-screen keyboard for input elements. |
| 4 | + |
3 | 5 | [](LICENSE) [](http://badge.fury.io/js/ngx-touch-keyboard) [](https://github.com/mohsen77sk/angular-touch-keyboard/actions)
|
4 | 6 |
|
5 |
| -## What is this? |
| 7 | + |
6 | 8 |
|
7 |
| -Virtual Keyboard for Angular applications. |
| 9 | +## Features |
8 | 10 |
|
9 |
| - |
| 11 | +- 📱 Responsive virtual keyboard |
| 12 | +- 🌐 Multiple locale support |
| 13 | +- 🎯 Flexible positioning |
| 14 | +- 🖥️ Full-screen mode support |
| 15 | +- 🎨 Customizable appearance |
| 16 | +- 🔧 Material Design integration |
10 | 17 |
|
11 | 18 | ## Demo
|
12 | 19 |
|
13 | 20 | [https://mohsen77sk.github.io/angular-touch-keyboard/](https://mohsen77sk.github.io/angular-touch-keyboard/)
|
14 | 21 |
|
15 |
| -## Install |
16 |
| - |
17 |
| -### Step 1: Install [ngx-touch-keyboard](https://www.npmjs.com/package/ngx-touch-keyboard) |
| 22 | +## Installation |
18 | 23 |
|
19 |
| -```sh |
| 24 | +```bash |
20 | 25 | npm install @angular/cdk ngx-touch-keyboard
|
21 | 26 | ```
|
22 | 27 |
|
23 |
| -### Step 2: Import the module |
| 28 | +## Compatibility |
| 29 | + |
| 30 | +The version of this library is synchronized with the major version of Angular to ensure compatibility. |
| 31 | + |
| 32 | +| Angular Version | Package Version | |
| 33 | +| --------------- | --------------- | |
| 34 | +| >= 18.0.0 | 4.x | |
| 35 | +| >= 16.0.0 | 3.x | |
| 36 | +| >= 14.0.0 | 2.x | |
| 37 | + |
| 38 | +## Basic Usage |
24 | 39 |
|
25 |
| -Add `ngxTouchKeyboardModule` as an import in your app's root NgModule. |
| 40 | +Import the `NgxTouchKeyboardModule` in your app.module.ts: |
26 | 41 |
|
27 | 42 | ```typescript
|
28 |
| -import { ngxTouchKeyboardModule } from 'ngx-touch-keyboard'; |
| 43 | +import { NgxTouchKeyboardModule } from 'ngx-touch-keyboard'; |
| 44 | + |
29 | 45 | @NgModule({
|
30 |
| - ... |
31 | 46 | imports: [
|
32 |
| - ... |
33 |
| - ngxTouchKeyboardModule, |
| 47 | + NgxTouchKeyboardModule |
34 | 48 | ],
|
35 |
| - ... |
36 | 49 | })
|
37 | 50 | export class AppModule { }
|
38 | 51 | ```
|
39 | 52 |
|
40 |
| -### Compatibility |
41 |
| - |
42 |
| -#### Version [`3.0.0`] |
| 53 | +If you want to set the custom locale, provide `NGX_TOUCH_KEYBOARD_LOCALE` by custom locale |
43 | 54 |
|
44 |
| -* `@angular/core`: `^16.0.0` || `^17.0.0` || `^18.0.0` |
45 |
| -* `@angular/cdk`: `^16.0.0` || `^17.0.0` || `^18.0.0` |
| 55 | +- default locale is `enUS` |
46 | 56 |
|
47 |
| -#### Version [`2.0.0`] |
| 57 | +```typescript |
| 58 | +import { NGX_TOUCH_KEYBOARD_LOCALE, faIR } from 'ngx-touch-keyboard'; |
48 | 59 |
|
49 |
| -* `@angular/core`: `^14.0.0` || `^15.0.0` |
50 |
| -* `@angular/cdk`: `^14.0.0` || `^15.0.0` |
| 60 | +@NgModule({ |
| 61 | + providers: [ |
| 62 | + { provide: NGX_TOUCH_KEYBOARD_LOCALE, useValue: faIR } |
| 63 | + ], |
| 64 | +}) |
| 65 | +export class AppModule { } |
| 66 | +``` |
51 | 67 |
|
52 |
| -## Localization |
| 68 | +Add the directive to your input elements: |
53 | 69 |
|
54 |
| -AngularTouchKeyboard is localized in 7 keyboard-specific locales: |
| 70 | +```html |
| 71 | +<input ngxTouchKeyboard [(ngxTouchKeyboardOpen)]="isOpen"> |
| 72 | +``` |
55 | 73 |
|
56 |
| -* `en-US` English (United States) (default) |
57 |
| -* `en-UK` English (United Kingdom) |
58 |
| -* `fa-IR` Persian (Iran) |
59 |
| -* `he-IL` Hebrew (Israel) |
60 |
| -* `ka-GE` Georgian (Georgia) |
61 |
| -* `ru-RU` Russian (Russia) |
62 |
| -* `sv-SE` Swedish (Sweden) |
| 74 | +## API Reference |
63 | 75 |
|
64 |
| -## Usage |
| 76 | +### Directives |
65 | 77 |
|
66 |
| -Simple usage example |
| 78 | +#### NgxTouchKeyboard |
67 | 79 |
|
68 |
| -```html |
69 |
| -<input |
70 |
| - type="text" |
71 |
| - ngxTouchKeyboard |
72 |
| - #touchKeyboard="ngxTouchKeyboard" |
73 |
| - (focus)="touchKeyboard.openPanel()" |
74 |
| -/> |
| 80 | +```typescript |
| 81 | +@Directive({ |
| 82 | + selector: 'input[ngxTouchKeyboard], textarea[ngxTouchKeyboard]' |
| 83 | +}) |
75 | 84 | ```
|
76 | 85 |
|
77 |
| -Locale usage example |
| 86 | +### Inputs |
| 87 | + |
| 88 | +| Name | Type | Default | Description | |
| 89 | +| --------------------------------- | ------------------------ | ------- | ---------------------------------------------- | |
| 90 | +| `ngxTouchKeyboardOpen` | `boolean` | `false` | Controls the visibility of the keyboard | |
| 91 | +| `ngxTouchKeyboardLocale` | `Locale` | `enUS` | Sets the keyboard locale | |
| 92 | +| `ngxTouchKeyboardFullScreen` | `boolean` | `false` | Enables full-screen mode | |
| 93 | +| `ngxTouchKeyboardDebug` | `boolean` | `false` | Enables debug mode | |
| 94 | +| `ngxConnectedTouchKeyboardOrigin` | `NgxTouchKeyboardOrigin` | `null` | Sets a custom origin for the keyboard position | |
| 95 | + |
| 96 | +### Methods |
| 97 | + |
| 98 | +- `openPanel()`: Opens the keyboard panel |
| 99 | +- `closePanel()`: Closes the keyboard panel |
| 100 | +- `togglePanel()`: Toggles the keyboard panel visibility |
| 101 | + |
| 102 | +## Material Design Integration |
| 103 | + |
| 104 | +The component automatically detects and integrates with Angular Material form fields, providing proper positioning and styling. |
| 105 | + |
| 106 | +## Advanced Usage |
| 107 | + |
| 108 | +### Custom locale |
78 | 109 |
|
79 | 110 | ```html
|
80 |
| -<input |
81 |
| - type="text" |
82 |
| - ngxTouchKeyboard="fa-IR" |
83 |
| - #touchKeyboard="ngxTouchKeyboard" |
84 |
| - (focus)="touchKeyboard.openPanel()" |
85 |
| -/> |
| 111 | +<input ngxTouchKeyboard [ngxTouchKeyboardLocale]="faIR"> |
86 | 112 | ```
|
87 | 113 |
|
88 |
| -Material usage example |
| 114 | +### Full-Screen Mode |
89 | 115 |
|
90 | 116 | ```html
|
91 |
| -<mat-form-field> |
92 |
| - <mat-label>Default</mat-label> |
93 |
| - <input |
94 |
| - matInput |
95 |
| - type="text" |
96 |
| - ngxTouchKeyboard |
97 |
| - #touchKeyboard="ngxTouchKeyboard" |
98 |
| - /> |
99 |
| - <button |
100 |
| - mat-icon-button |
101 |
| - matSuffix |
102 |
| - type="button" |
103 |
| - (click)="touchKeyboard.togglePanel()" |
104 |
| - > |
105 |
| - <mat-icon> keyboard </mat-icon> |
106 |
| - </button> |
107 |
| -</mat-form-field> |
| 117 | +<input ngxTouchKeyboard [ngxTouchKeyboardFullScreen]="true"> |
108 | 118 | ```
|
109 | 119 |
|
110 |
| -### Properties |
| 120 | +### Custom Position Origin |
111 | 121 |
|
112 |
| -| Property | Description | |
113 |
| -| ---------------------------- | ----------------------------------------------------------- | |
114 |
| -| `ngxTouchKeyboard` | Required to initialize Virtual Keyboard to specified input. | |
115 |
| -| `ngxTouchKeyboardDebug` | Debug mode is on. | |
116 |
| -| `ngxTouchKeyboardFullScreen` | Full screen mode is on. | |
| 122 | +```html |
| 123 | +<div ngxTouchKeyboardOrigin #origin="ngxTouchKeyboardOrigin"> |
| 124 | + <input ngxTouchKeyboard [ngxConnectedTouchKeyboardOrigin]="origin"> |
| 125 | +</div> |
| 126 | +``` |
117 | 127 |
|
118 |
| -### Methods |
| 128 | +## Localization |
119 | 129 |
|
120 |
| -Here's the list of all available methods: |
| 130 | +AngularTouchKeyboard is localized in 7 keyboard-specific locales: |
121 | 131 |
|
122 |
| -| Methods | Description | |
123 |
| -| --------------------- | --------------------- | |
124 |
| -| `openPanel(): void` | Open keyboard panel | |
125 |
| -| `closePanel(): void` | Close keyboard panel | |
126 |
| -| `togglePanel(): void` | Toggle keyboard panel | |
| 132 | +* `en-US` English (United States) (default) |
| 133 | +* `en-UK` English (United Kingdom) |
| 134 | +* `fa-IR` Persian (Iran) |
| 135 | +* `he-IL` Hebrew (Israel) |
| 136 | +* `ka-GE` Georgian (Georgia) |
| 137 | +* `ru-RU` Russian (Russia) |
| 138 | +* `sv-SE` Swedish (Sweden) |
127 | 139 |
|
128 | 140 | ## Themes
|
129 | 141 |
|
@@ -167,6 +179,10 @@ The most useful commands for development are:
|
167 | 179 | * `npm run start` to start a development server
|
168 | 180 | * `npm run build-demo` to build the demo locally (it will be published automatically by GitHub Actions)
|
169 | 181 |
|
| 182 | +## Contributing |
| 183 | + |
| 184 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 185 | + |
170 | 186 | ## License
|
171 | 187 |
|
172 | 188 | [The MIT License (MIT)](LICENSE)
|
0 commit comments