Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@autosys/react-mui-keyboard

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@autosys/react-mui-keyboard

This is an example application featuring a virtual on-screen keyboard, developed using React and Material-UI (MUI).

  • 1.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25
decreased by-45.65%
Maintainers
2
Weekly downloads
 
Created
Source

On-Screen Keyboard App

This is an example application featuring a virtual on-screen keyboard, developed using React and Material-UI (MUI).

TypeScript React MUI

Yarn Licence

Read this in other languages: Русский

Screenshot

With this application, users can input text using the virtual keyboard, select the keyboard layout language (Russian or English), use Caps Lock, Backspace, Space, and Enter keys.

Installation:

NPM

Install with npm:

npm install @autosys/react-mui-keyboard

Install with yarn:

yarn add @autosys/react-mui-keyboard

Usage

  1. To input text, click on the virtual keyboard buttons or use the Caps Lock, Backspace, Space, and Enter keys.

  2. To change the keyboard layout language, click on the "RU" button (Russian layout) or "EN" button (English layout).

Technologies

  • React: JavaScript library for building user interfaces.
  • Material-UI (MUI): Component library for creating stylish user interfaces.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Example Usage:

import React, { useState } from 'react';
import { TextField } from '@mui/material';
import { MuiKeyboard } from '@autosys/react-mui-keyboard';
import { russianButtons, englishButtons, numbers } from 'path_to_your_button_data';

const App = () => {
  const [checked, setChecked] = useState(false);
  const [inputValue, setInputValue] = useState<string>('');

  const handleUrlChange = (event: React.ChangeEvent<HTMLInputElement>) => {
    setInputValue(event.target.value);
  };

  const handleChange = () => {
    setChecked((prev) => !prev);
  };

  return (
    <MuiKeyboard
      textField={
        <TextField
          onChange={handleUrlChange}
          onClick={handleChange}
          value={inputValue}
          fullWidth
          multiline
        />
      }
      slide
      direction="up"
      checked={checked}
      setInputValue={setInputValue}
      numbers={numbers}
      firstLanguage={russianButtons}
      secondLanguage={englishButtons}
      secondLangLabel="EN"
      firstLangLabel="RU"
      keyboardWidth={'900px'}
      buttonSize="medium"
      labelLangButton
      reverseButton
      sx={{ display: 'flex' }}
    />
  );
};

export default App;

Usage without TextField and with Context

If you want to use the MuiKeyboard component without a built-in TextField and manage the input value using context, follow these steps:

  1. Wrap your application with the MuiKeyboardProvider:
// index.tsx
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { MuiKeyboardProvider } from '@autosys/react-mui-keyboard';
import { russianButtons } from '@autosys/react-mui-keyboard';

ReactDOM.render(
  <MuiKeyboardProvider
    firstLanguage={russianButtons}
    sx={{ display: 'flex', justifyContent: 'center', mt: 50 }}
    keyboardWidth={'900px'}
  >
    <App />
  </MuiKeyboardProvider>,
  document.getElementById('root'),
);
  1. Then yo may use the useMuiKeyboard hook in any another component to access the input value and setter from the context.
// App.tsx
import React from 'react';
import { TextField } from '@mui/material';
import { useMuiKeyboard } from '@autosys/react-mui-keyboard';

const App = () => {
  const { inputValue, keyboardFeature } = useMuiKeyboard();
  return (
    <TextField
      value={inputValue}
      onClick={() => keyboardFeature({ slideEffect: true })}
      label="Click!"
    >
      Hello
    </TextField>
  );
};

export default App;

If you want your component (for example, a button) to only be able to close the keyboard, use onClick={() => keyboardFeature({ slideEffect: false })}

Example_context

If you want to reset the inputValue, but don't want to do it with a button on the keyboard, you can use any other button with onClick={() => keyboardFeature({ resetText: true })}

Examples:

singlyBack and betweenButtons

If you want the backspace key to be separate, use the singlyBack prop. You can also use the betweenButtons prop to increase the distance between the keys.

Example_singlyBack

labelLetterButton

If you want to use numbers separately from letters, then use the labelLetterButton prop. You can also use the numberColumns and numbersRows props to change columns and rows in a numeric block.

Example_labelLetter Example_labelLetter_numbers

Properties

NameTypeDescription
textFieldJSX.ElementText input field component.
slidebooleanA flag indicating whether the keyboard should appear with a Slide animation. By default, true.
directionSlideProps <"left" | "right" | "up" | "down">Slide animation direction (used if slide is set to true). By default, up.
checkedbooleanKeyboard visibility state flag.
setInputValueReact.Dispatch<React.SetStateAction<string>>Callback to set the input field's value.
numbersstring[]Array of characters for keyboard number buttons.
firstLanguage*string[]Array of characters for keyboard buttons in the first language.
secondLanguagestring[]Array of characters for keyboard buttons in the second language.
secondLangLabelstringLabel for the second language.
firstLangLabelstringLabel for the first language.
keyboardWidthstring | numberKeyboard width.
buttonSizeButtonProps <"small" | "medium" | "large">Button size.
labelLangButtonbooleanLanguage switch button.
reverseButtonbooleanText reset button.
singlyBackbooleanIf true, the backspace button is separate from the block with numbers.
labelLetterButtonbooleanIf true, a button is added to switch between the layout with letters and numbers.
betweenButtonsstring | numberDistance between buttons.
numbersColumnsstringThe number of columns for numeric keypad when it is separate from letters. By default, 5.
numbersRowsstringThe number of rows for numeric keypad when it is separate from letters. By default, 3.
allKeyboardStyleSxPropsThe sx prop is a shortcut for defining custom styles that has access to the theme.
timeoutSlideProps <number | { appear?: number, enter?: number, exit?: number }>The duration for the transition, in milliseconds. You may specify a single timeout for all transitions, or individually with an object.

Props marked with * are required.

Keywords

FAQs

Package last updated on 24 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc