Skip to content

Commit

Permalink
JavaScript > Event > Keyboard Event > add
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMadWill committed Nov 10, 2021
1 parent d7e84c4 commit 26b60f2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 8_Events/Html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 class="app-title" id="header">To Do App</h1>
<input id="txtTaskName" name="taskName" type="text" class="form-control" placeholder="Type a new task"
aria-describedby="btnAddNewTask">
<div class="input-group-append">
<button class="btn btn-primary" type="button" id="btnAddNewTask">
<button class="btn btn-primary" type="submit" id="btnAddNewTask">
<i class="fas fa-plus"></i>
</button>
</div>
Expand Down
33 changes: 29 additions & 4 deletions 8_Events/JavaScripts/21_8_3_Keyboard_Event.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
// Keyboard Event
const input = document.querySelector('#txtTaskName');

const form = document.querySelector("form")

//** Keyboard Press
input.addEventListener('keydown',eventHandler)
//input.addEventListener('keydown',eventHandler)

//** Keyboard Break up
input.addEventListener('keyup',eventHandler)
// input.addEventListener('keyup',eventHandler)

//** Keyboard Press
//input.addEventListener('keypress',eventHandler)

//** Focus
// input.addEventListener('focus',eventHandler)

//** Cut -> control + x -> press
// input.addEventListener('cut',eventHandler)

//** Paste -> control + v -> press
// input.addEventListener('paste',eventHandler)

//*-* Submit
form.addEventListener('submit',eventHandler)

//*-* Select
input.addEventListener('select',eventHandler)



function eventHandler(x){
console.log(`Event type : ${x.type}`);
console.log(`Event type : ${x.type} , Keyboard Code: ${x.keyCode} , Keyboard Value: ${x.target.value} `);


// x.preventDefault()
// x.target.style.backgroundColor='yellow'
}

0 comments on commit 26b60f2

Please sign in to comment.