Easily create key board shortcuts for your JS functions. Built using JS only with no other dependency. Inspired from MacOS spotlight

Overview

floodlightjs

Inspired from macOS spotlight, floodlight is simple JS library that will show a search area. How the search is handled is completely on you.

You can register any key. To run it will bind an event with your specified key and shift

Important: esc closes floodlight!

Installation

From CDN

<script src="https://cdn.jsdelivr.net/gh/rajnandan1/[email protected]/dist/floodlight.min.js"></script>

Demo

Live instance of Floodlight

Basic Usage - Implement a quick google search shift+g

The below code implements a google search using floodgate. It will listen for the g key. When someone presses shift+g it will show a search box.

let fl = new FloodLight();

//this takes to parameters. first parameter is the `key`, second is the description
let cmd = fl.addCommand("g", "Search Something in google");

//Implement a function that would handle the query. Takes one parameter
let implementSearchInGoogle = function(obj) {
	location.href = "https://www.google.com/search?q=" + encodeURI(obj.query)
};

//Add the action for a command. Takes in a string array, a description and a function
cmd.addAction(["query"], "search {query} in google", implementSearchInGoogle);

//Start floodlight. It will start listening
fl.run();

Multiple Commands - Add Social media search shift+s

The below code implements a social search using floodgate. It will listen for the s key. It attaches two actions to one command.

let fl = new FloodLight();
let cmdSocial = fl.addCommand("s", "Search user name in social media");

//Adding twitter
let implementSearchTwitter = function(obj) {
	location.href = "https://twitter.com/" + encodeURI(obj.query)
};
cmdSocial.addAction(["query"], "search {query} in twitter", implementSearchTwitter);

//Adding facebook
let implementSearchFB = function(obj) {
	location.href = "https://www.facebook.com/" + encodeURI(obj.query)
};
cmdSocial.addAction(["query"], "search {query} in facebook", implementSearchFB);
//Start floodlight. It will start listening
fl.run();

Multiple Params, Multiple Commands - Add, Subtract, Multiply two or three numbers shift+c

The below code implements arithmetic operation. It will listen for the c key. It accepts more than one param.

let fl = new FloodLight();
let cmdCal = fl.addCommand("c", "Provide comma separated numbers");

//Add 2 numbers
let add = function(obj) {
	alert(Number(obj.num1) + Number(obj.num2))
};
cmdCal.addAction(["num1", "num2"], "{num1} + {num2}", add);

//Subtract 2 numbers
let sub = function(obj) {
	alert(Number(obj.num1) - Number(obj.num2))
};
cmdCal.addAction(["num1", "num2"], "{num1} - {num2}", sub);

//Multiply 3 numbers
let mul = function(obj) {
	alert(Number(obj.num1) * Number(obj.num2) * Number(obj.num3))
};
cmdCal.addAction(["num1", "num2", "num3"], "{num1} x {num2} x {num3}", mul);
fl.run();

Customizations

Floodlightjs gives you control over how the UI elements look. You can pass a class for advanced handling or use simple colors.

Simple Colors light or dark theme

let config = {
	theme: {
		dark:{ //light or dark
			primary: "#111",
			secondary: "#231e24"
		}
	}
}
let fl = new FloodLight(config);

Add your class

let config = {
	cssClassPrefix: "fooclass"
}	

//It will add this prefix in all the UI elements
let fl = new FloodLight(config);

Add your CSS

//Once added you can handle CSS like this
.fooclass-wrapper{
	/*Main Overlay Component*/
}
.fooclass-search{
	/*Main Component*/
}
.fooclass-input{
	/*Search Component*/
}
.fooclass-dropdown{
	/*Dropdown Component*/
}
.fooclass-item{
	/*Items Component*/
}
You might also like...

SimpleProject is a web app that allows users to create projects and manage them in a Kanban board.

SimpleProject is a web app that allows users to create projects and manage them in a Kanban board.

What is SimpleProject SimpleProject is a web app that allows users to create projects and manage them in a kanban board. SimpleProject was built with

Nov 23, 2022

A low-feature, dependency-free and performant test runner inspired by Rust and Deno

minitest A low-feature, dependency-free and performant test runner inspired by Rust and Deno Simplicity: Use the mt test runner with the test function

Nov 12, 2022

A functional, immutable, type safe and simple dependency injection library inspired by angular.

func-di English | 简体中文 A functional, immutable, type safe and simple dependency injection library inspired by Angular. Why func-di Installation Usage

Dec 11, 2022

A Leaderboard app that pulls from a LeaderboardGameAPI and allows users to view recent scores and add more scores to the score board. Built with HTML5, CSS, JavaScript, and Webpack.

A Leaderboard app that pulls from a LeaderboardGameAPI and allows users to view recent scores and add more scores to the score board. Built with HTML5, CSS, JavaScript, and Webpack.

Leaderboard A Leaderboard app that pulls from a LeaderboardGameAPI and allows users to view recent scores and add more scores to the score board. Buil

Dec 21, 2022

Awesome Books project with ES6 is an application that was built using Vanilla JavaScript with ES6 features like using arrow functions. This application allows you to keep records of your favorite books.

Javascript Project Awesome Books with ES6 Using Javascript to create a simple Awesome Books project. Populating the books list and then removing one b

Sep 28, 2022

A vscode extension to quickly print variable, variable type, tensor shape etc by using shortcuts

A vscode extension to quickly print variable, variable type, tensor shape etc by using shortcuts

Quick Python Print This repo is inspired by "Python Quick Print". "Python Quick Print" can quickly print out variables on the console by using shortcu

Oct 28, 2022

Functions Recipes is a library of examples to help you getting started with Salesforce Functions and get used to their main features.

Functions Recipes is a library of examples to help you getting started with Salesforce Functions and get used to their main features.

Functions Recipes Introduction Salesforce Functions lets you use the Salesforce Platform for building event-driven, elastically scalable apps and expe

Dec 29, 2022

🎛 Desktop application (Windows / macOS / Linux) for Home Assistant built with Electron

🎛 Desktop application (Windows / macOS / Linux) for Home Assistant built with Electron

Home Assistant - Desktop Desktop App (Windows / macOS / Linux) for Home Assistant built with Electron Installation Just download the latest version fo

Dec 11, 2022
Releases(1.0.6)
Owner
Raj Nandan Sharma
https://rajnandan1.github.io/
Raj Nandan Sharma
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Tool to sign data with a Cardano-Secret-Key // verify data with a Cardano-Public-Key // generate CIP-8 & CIP-36 data

Tool to sign data with a Cardano-Secret-Key // verify data with a Cardano-Public-Key // generate CIP-8 & CIP-36 data

Martin Lang 11 Dec 21, 2022
The only job board you will ever need.

Jobilist A stunning job search engine that helps job seekers find the perfect employment opportunity by connecting them with the best employers around

Jobilist 14 Dec 23, 2022
Instant spotlight like search and actions in your browser with Sugu Search.

Sugu Search Instant spotlight like search and actions in your browser with Sugu Search. Developed by Drew Hutton Grab it today for Firefox and Chrome

Drew Hutton (Yoroshi) 9 Oct 12, 2022
Spotlight! but for Developers.

Auxilium Auxilium is an app built to look and feel like the spotlight app for mac, but is made for developers, so you can find solutions on stack over

Nav 13 Dec 15, 2022
Bookmate - Watch changes in Chrome bookmarks, and use bookmarks as an append-only key-value store via an fs-like API.

?? Bookmate An append-only key-value store built on Chrome bookmarks, plus an asychronous stream of Bookmark changes. For NodeJS Actual production exa

Cris 6 Nov 8, 2022
Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.

Atomico simplifies learning, workflow and maintenance when creating webcomponents. Scalable and reusable interfaces: with Atomico the code is simpler

Atomico 898 Dec 31, 2022