Giter Site home page Giter Site logo

keydisplayvueplugin's Introduction

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

KeyDisplay Vue 3 Plugin

A standalone Vue 3 plugin to display and handle shortcuts and key presses.
Report Bug ยท Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

About The Project

Product Name Screen Shot

Product Name Screen Shot

KeyDisplayPlugin ,as the name implies, is a plugin for Vue 3 that displays key pressed on your screen and link them to events as shortcut. KeyDisplayPlugin is a standalone component and require almost no dependencies.

(back to top)

Built With

Vue

(back to top)

Getting Started

Installation

To start using KeyDisplayPLugin:

  1. Install KeyDisplayPlugin using your package manager.
  • npm
    npm i vue-keys-display
  • yarn
    yarn install vue-keys-display
  • pnpm
    pnpm install vue-keys-display
  1. Import the plugin and use it

    import KeyDisplayPlugin from "vue-plugin-key-display";
    import App from "./App.vue";
    
    const app = createApp(App);
    app.use(KeyDisplayPlugin);
  2. (Optional) Import default CSS styling

    import "vue-plugin-key-display/style.css";
  3. Use the KeyAnchor component

<main
  class="flex items-center justify-center h-full overflow-scroll background-wrapper"
>
  <!-- Put anywhere in your app. For default css Styling, put it under body or your root -->
  <KeyAnchor
    :fadeDelay="1500"
    :displayOnEventCallOnly="false"
    :events="[events]"
    :blackList="[blacklisted]"
    :KeyCtrlStyleObject="{ color: 'red' }"
    :numberOfKeyGroupDisplayed="8"
  />
  <!-- Rest of you code Here -->
</main>

(back to top)

Usage

Using the plugin is pretty straight forward, use the props on KeyAnchor component to customize the behaviour. Below is a list of props accepted by option object.

KeyAnchor props

interface KeyPluginOptions {
  KeyAnchorStyleObject?: StyleValue | undefined;
  KeyContainerStyleObject?: StyleValue | undefined;
  KeyGroupStyleObject?: StyleValue | undefined;
  KeyBlocStyleObject?: StyleValue | undefined;
  KeyAltStyleObject?: StyleValue | undefined;
  KeyShiftStyleObject?: StyleValue | undefined;
  KeyCtrlStyleObject?: StyleValue | undefined;
  fadeDelay?: number;
  numberOfKeyGroupDisplayed?: number;
  blackList?: KeyEntity[];
  events?: KeyEntity[];
  displayOnEventCallOnly?: boolean;
}
Props Description Type Default Example
KeyAnchorStyleObject Represents inline styling applied to the outer keys wrapper This is the direct parent to the keys container StyleValue/undefined undefined { position: 'absolute', top: '50%', left: '50%' }
KeyContainerStyleObject Represents inline styling applied to the inner keys wrapper. This is the direct parent to the keys Group StyleValue/undefined undefined { padding: '3rem' }
KeyGroupStyleObject Reperents inline styling applied to a key group. this is the direct parent to keys blocs. StyleValue/undefined undefined { background-color: 'red', fontSize: '30px' }
KeyBlocStyleObject Reperents inline styling applied to a key bloc. StyleValue/undefined undefined { color: 'blue' }
KeyAltStyleObject Reperents inline styling applied to the Alt bloc. StyleValue/undefined undefined { color: 'green' }
KeyShiftStyleObject Reperents inline styling applied to the Alt bloc. StyleValue/undefined undefined { color: 'yellow' }
KeyCtrlStyleObject Reperents inline styling applied to the Alt bloc. StyleValue/undefined undefined { color: 'purple' }
fadeDelay Time in ms before key group fade out Number 2000 5000
numberOfKeyGroupDisplayed Number of key groups displayed at the same time Number 3 8
blackList Array of KeyEntities to blacklist KeyEntity[] undefined See below
events Array of keyEntities that will call their function on press KeyEntity[] undefined See below
displayOnEventCallOnly Boolean to show keys displayed only if they are linked to an events in the Events props Boolean false
// Constructor parameter of KeyEntity.ts
    private _content: string,
    private _modifiersKeyState: ModifiersKeysState = {
      altPressed: false,
      ctrlPressed: false,
      shiftPressed: false,
    },
    readonly _callback?: (...params: any) => void,
    private readonly _message?: string

Examples:

<template>
  <main
    class="flex items-center justify-center h-full overflow-scroll background-wrapper"
  >
    <KeyAnchor
      :fadeDelay="1500"
      :displayOnEventCallOnly="false"
      :events="[events]"
      :blackList="[blacklisted]"
      :KeyCtrlStyleObject="{ color: 'red' }"
      :numberOfKeyGroupDisplayed="8"
    />
    <h1 class="font-serif text-center dark:text-white text-7xl">
      KeyDisplayPlugin
    </h1>
  </main>
</template>

<script lang="ts">
  import { KeyAnchor, KeyEntity } from "vue-keys-display";

  export default {
    setup() {
      const events = new KeyEntity(
        "A",
        { altPressed: false, ctrlPressed: true, shiftPressed: false },
        () => {
          console.log("hello world from console");
        },
        "hello world ๐Ÿ˜‚ on screen"
      );
      const blacklisted = new KeyEntity("X", {
        ctrlPressed: true,
        altPressed: false,
        shiftPressed: false,
      });
      return { events, blacklisted };
    },
    components: { KeyAnchor },
  };
</script>

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Mehdi Mani - [email protected]

Project Link: https://github.com/Mehdi-Mani/KeyDisplayVuePlugin

(back to top)

Acknowledgments

Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!

(back to top)

keydisplayvueplugin's People

Contributors

mehdi-mani avatar

Stargazers

 avatar Mohamed Bashar Touil avatar Hamza Ben Romdhane avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.