changed default behavior of arrows in game

+ small css improvments in game
This commit is contained in:
simplonco
2023-01-14 21:34:53 +01:00
parent 888255c810
commit a060ddf4e9
3 changed files with 17 additions and 4 deletions

View File

@@ -13,6 +13,8 @@ body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
/* tmp? */ /* tmp? */
background: bisque; background: bisque;
display: flex;
flex-direction: column;
} }
a { a {

View File

@@ -348,11 +348,16 @@
} }
#game_page { #game_page {
margin: 0; margin: 0;
padding: 20px;
background-color: #222425; background-color: #222425;
position: relative; position: relative;
width: 100%; width: 100%;
height: 100%; height: auto;
display: flex;
flex-direction: column;
flex-grow: 1;
}
#game_option {
margin-top: 20px;
} }
#canvas_container { #canvas_container {
margin-top: 20px; margin-top: 20px;

View File

@@ -59,14 +59,20 @@ function start_after_countdown()
abortControllerKeydown = new AbortController(); abortControllerKeydown = new AbortController();
window.addEventListener( window.addEventListener(
'keydown', 'keydown',
(e) => { pong.addKey(e.key); }, (e) => {
e.preventDefault();
pong.addKey(e.key);
},
{signal: abortControllerKeydown.signal} {signal: abortControllerKeydown.signal}
); );
abortControllerKeyup = new AbortController(); abortControllerKeyup = new AbortController();
window.addEventListener( window.addEventListener(
'keyup', 'keyup',
(e) => { pong.deleteKey(e.key); }, (e) => {
e.preventDefault();
pong.deleteKey(e.key);
},
{signal: abortControllerKeyup.signal} {signal: abortControllerKeyup.signal}
); );